Module: ThemeBandit::URLFormatter
Instance Method Summary collapse
-
#resolve_dot_dots(host, path) ⇒ Object
returns an aboslute url with dot dot syntax removed.
- #strip_query_string(str) ⇒ Object
Instance Method Details
#resolve_dot_dots(host, path) ⇒ Object
returns an aboslute url with dot dot syntax removed
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/theme_bandit/url_formatter.rb', line 8 def resolve_dot_dots(host, path) number_of_dot_dots = path.split('/').select { |v| v == '..' }.length if number_of_dot_dots > 0 new_path = path.gsub('../', '') new_host = host.split('/') new_host.pop(number_of_dot_dots + 1) new_host.push(new_path).join('/') else "#{host}#{path}" end end |
#strip_query_string(str) ⇒ Object
3 4 5 |
# File 'lib/theme_bandit/url_formatter.rb', line 3 def strip_query_string(str) str.split('?').first end |