Module: Ajax::Helpers::UrlHelper
- Defined in:
- lib/ajax/helpers/url_helper.rb
Instance Method Summary collapse
-
#hashed_url_from_fragment(url) ⇒ Object
Return a hashed URL using the fragment of
url
. -
#hashed_url_from_traditional(url) ⇒ Object
Return a hashed URL formed from a traditional
url
. -
#is_hashed_url?(url) ⇒ Boolean
The URL is hashed if the fragment part starts with a /.
-
#traditional_url_from_fragment(url) ⇒ Object
Return a traditional URL from the fragment of
url
. -
#url_is_root?(url) ⇒ Boolean
Return a boolean indicating whether the given URL points to the root path.
Instance Method Details
#hashed_url_from_fragment(url) ⇒ Object
Return a hashed URL using the fragment of url
19 20 21 |
# File 'lib/ajax/helpers/url_helper.rb', line 19 def hashed_url_from_fragment(url) url_host(url) + ('/#/' + (encode_and_parse_url(url).fragment || '')).gsub(/\/\//, '/') end |
#hashed_url_from_traditional(url) ⇒ Object
Return a hashed URL formed from a traditional url
29 30 31 32 33 34 |
# File 'lib/ajax/helpers/url_helper.rb', line 29 def hashed_url_from_traditional(url) uri = encode_and_parse_url(url) hashed_url = url_host(url) + ('/#/' + (uri.path || '')).gsub(/\/\//, '/') hashed_url += ('?' + uri.query) unless uri.query.nil? hashed_url end |
#is_hashed_url?(url) ⇒ Boolean
The URL is hashed if the fragment part starts with a /
For example, lol.com#/Rihanna
14 15 16 |
# File 'lib/ajax/helpers/url_helper.rb', line 14 def is_hashed_url?(url) !!(encode_and_parse_url(url).fragment=~ %r[^\/]) end |
#traditional_url_from_fragment(url) ⇒ Object
Return a traditional URL from the fragment of url
24 25 26 |
# File 'lib/ajax/helpers/url_helper.rb', line 24 def traditional_url_from_fragment(url) url_host(url) + ('/' + (encode_and_parse_url(url).fragment || '')).gsub(/\/\//, '/') end |
#url_is_root?(url) ⇒ Boolean
Return a boolean indicating whether the given URL points to the root path.
7 8 9 |
# File 'lib/ajax/helpers/url_helper.rb', line 7 def url_is_root?(url) !!(encode_and_parse_url(url).path =~ %r[^\/?$]) end |