Sha256: fa16acfbc3620e41a0fbfb8377e8ec689460d04755f687e83618c024ecca6f7a
Contents?: true
Size: 889 Bytes
Versions: 1
Compression:
Stored size: 889 Bytes
Contents
module MobileEnhancements module UrlHelper def url_for(*args) url = super # ignore our direct calls for desktop/mobile URLs if args.size == 1 && args.first.frozen? url # if it's from a mobile elsif mobile_request? # mobilify the url murl = mobile_url(url) # verify or resort to original verify_path(murl) || url # if it's a desktop request else # desktopify the url durl = desktop_url(super) # verify or resort to original verify_path(durl) || durl end end # ensures a URL/path exists def verify_path(url) path = strip_domain(url) Rails.application.routes.recognize_path(path) && url rescue false end # converts a URL/path to a path def strip_domain(url) url.gsub(/([a-z]+\:)?\/\/.*?\//i, "/") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mobile-enhancements-0.0.5 | lib/mobile_enhancements/url_helper.rb |