Sha256: 38572f5727d130b51c4207f35389ba3f894714cc3ce0300209a7a7a78d9c836f
Contents?: true
Size: 796 Bytes
Versions: 31
Compression:
Stored size: 796 Bytes
Contents
class VanityUrlPage < Page def clean_target_url (self.target_url.match('http://') || self.target_url.match('https://')) ? self.target_url : VanityUrlPage.clean_path(self.target_url) end class << self def find_vanity_url_by_path(path, live = true) vanity_url_page = Page.current_site.homepage.children.find_by_slug('vanity-urls') vanity_pages = vanity_url_page.children.where("vanity_url like '%#{path}%'") vanity_pages.each do |vanity_page| return vanity_page if clean_comparison_path(path).downcase == clean_comparison_path(vanity_page.vanity_url).downcase end nil end def clean_comparison_path(path) "#{clean_path(path)}/" end def clean_path(path) "/#{path.to_s.strip}".gsub(%r{//+}, '/') end end end
Version data entries
31 entries across 31 versions & 1 rubygems