module ThemeBandit::URLFormatter
Public Instance Methods
cdn_to_fqd(src)
click to toggle source
# File lib/theme_bandit/url_formatter.rb, line 7 def cdn_to_fqd(src) src[/^\/\//] ? "http:#{src}" : src end
get_absolute_path(old_path, new_path)
click to toggle source
returns resolved path, ready for use with host
# File lib/theme_bandit/url_formatter.rb, line 12 def get_absolute_path(old_path, new_path) number_of_dot_dots = new_path.split('/').select { |v| v == '..' }.length if number_of_dot_dots > 0 # TODO: should be separate method new_path = new_path.gsub('../', '') old_path = old_path.split('/') old_path.pop(number_of_dot_dots + 1) new_path = old_path.push(new_path).join('/') "#{path_with_leading_slash(new_path)}" else "#{path_with_leading_slash(new_path)}" end end
path_with_leading_slash(str)
click to toggle source
# File lib/theme_bandit/url_formatter.rb, line 26 def path_with_leading_slash(str) str[/^\//] ? str : "/#{str}" end
strip_query_string(str)
click to toggle source
# File lib/theme_bandit/url_formatter.rb, line 3 def strip_query_string(str) str.split('?').first end