-require "uri"
+require "cgi"
module BrowseHelper
def printable_name(object, version = false)
private
- ICON_TAGS = %w(aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway).freeze
+ ICON_TAGS = %w[aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway].freeze
def icon_tags(object)
object.tags.find_all { |k, _v| ICON_TAGS.include? k }.sort
# the correct page.
lookup_us = lookup.tr(" ", "_")
- if page = WIKI_PAGES[locale][type][lookup_us] rescue nil
+ if page = WIKI_PAGES.dig(locale, type, lookup_us)
url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
- elsif page = WIKI_PAGES["en"][type][lookup_us] rescue nil
+ elsif page = WIKI_PAGES.dig("en", type, lookup_us)
url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
end
# Must break it up to correctly build the url
value = Regexp.last_match(1)
section = "#" + Regexp.last_match(2)
- encoded_section = "#" + URI.encode(Regexp.last_match(2).gsub(/ +/, "_"), /[^A-Za-z0-9:_]/).tr("%", ".")
+ encoded_section = "#" + CGI.escape(Regexp.last_match(2).gsub(/ +/, "_")).tr("%", ".")
else
section = ""
encoded_section = ""