end
safe_join(phones, "; ")
elsif colour_value = colour_preview(key, value)
- content_tag(:span, "", :class => "colour-preview-box", :"data-colour" => colour_value, :title => t("browse.tag_details.colour_preview", :colour_value => colour_value)) + colour_value
+ tag.span("", :class => "colour-preview-box", :"data-colour" => colour_value, :title => t("browse.tag_details.colour_preview", :colour_value => colour_value)) + colour_value
else
linkify h(value)
end
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
# Value is <title> 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
# 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 = ""
#
# Also accepting / as a visual separator although not given in RFC 3966,
# because it is used as a visual separator in OSM data in some countries.
- if value.match?(%r{^\s*\+[\d\s\(\)/\.-]{6,25}\s*(;\s*\+[\d\s\(\)/\.-]{6,25}\s*)*$})
+ if value.match?(%r{^\s*\+[\d\s()/.-]{6,25}\s*(;\s*\+[\d\s()/.-]{6,25}\s*)*$})
return value.split(";").map do |phone_number|
# for display, remove leading and trailing whitespace
phone_number = phone_number.strip