From: Kyle Hensel Date: Sat, 31 Dec 2022 03:37:29 +0000 (+1300) Subject: fix formatting of tag values with semicolon-separated URLs X-Git-Tag: live~843^2~1 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/305acfe5167dec7440448cfa02e6c1430286c742 fix formatting of tag values with semicolon-separated URLs --- diff --git a/app/helpers/browse_tags_helper.rb b/app/helpers/browse_tags_helper.rb index 0784d03ca..b7c12ca60 100644 --- a/app/helpers/browse_tags_helper.rb +++ b/app/helpers/browse_tags_helper.rb @@ -32,7 +32,7 @@ module BrowseTagsHelper elsif colour_value = colour_preview(key, 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) + safe_join(h(value).split(";").map{|x| linkify(x) }, ";") end end diff --git a/test/helpers/browse_tags_helper_test.rb b/test/helpers/browse_tags_helper_test.rb index 3f36b9210..2329a7c96 100644 --- a/test/helpers/browse_tags_helper_test.rb +++ b/test/helpers/browse_tags_helper_test.rb @@ -49,6 +49,12 @@ class BrowseTagsHelperTest < ActionView::TestCase html = format_value("contact", "foo@example.com") assert_dom_equal "foo@example.com", html + + html = format_value("source", "https://example.com") + assert_dom_equal "https://example.com", html + + html = format_value("source", "https://example.com;hello;https://example.net") + assert_dom_equal "https://example.com;hello;https://example.net", html end def test_wiki_link