X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/39b60219fe37d1e3f94555a053895adc1eee179c..b70da7b8ea15ab48bb2f34155567cea6dffc8fc9:/app/helpers/browse_tags_helper.rb diff --git a/app/helpers/browse_tags_helper.rb b/app/helpers/browse_tags_helper.rb index 5acbba9c7..146664914 100644 --- a/app/helpers/browse_tags_helper.rb +++ b/app/helpers/browse_tags_helper.rb @@ -58,9 +58,10 @@ module BrowseTagsHelper def wikipedia_link(key, value) # Some k/v's are wikipedia=http://en.wikipedia.org/wiki/Full%20URL - return nil if value =~ %r{^https?://} + return nil if %r{^https?://}.match?(value) - if key == "wikipedia" + case key + when "wikipedia" # This regex should match Wikipedia language codes, everything # from de to zh-classical lang = if value =~ /^([a-z-]{2,12}):(.+)$/i @@ -71,7 +72,7 @@ module BrowseTagsHelper # Value is so default to English Wikipedia "en" end - elsif key =~ /^wikipedia:(\S+)$/ + when /^wikipedia:(\S+)$/ # Language is in the key, so assume value is the title lang = Regexp.last_match(1) else @@ -83,8 +84,8 @@ module BrowseTagsHelper # Contains a reference to a section of the wikipedia article # Must break it up to correctly build the url value = Regexp.last_match(1) - section = "#" + Regexp.last_match(2) - encoded_section = "#" + CGI.escape(Regexp.last_match(2).gsub(/ +/, "_")).tr("%", ".") + section = "##{Regexp.last_match(2)}" + encoded_section = "##{CGI.escape(Regexp.last_match(2).gsub(/ +/, '_')).tr('%', '.')}" else section = "" encoded_section = ""