From 07436bc1b0fe82d702c5b167154bb1c48e7a2232 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 14 Dec 2023 18:08:06 +0300 Subject: [PATCH] Keep trailing semicolons in formatted tag values --- app/helpers/browse_tags_helper.rb | 2 +- test/helpers/browse_tags_helper_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/helpers/browse_tags_helper.rb b/app/helpers/browse_tags_helper.rb index 014b8262d..1bda7dcb7 100644 --- a/app/helpers/browse_tags_helper.rb +++ b/app/helpers/browse_tags_helper.rb @@ -36,7 +36,7 @@ module BrowseTagsHelper elsif colour_value = colour_preview(key, value) tag.span("", :class => "colour-preview-box float-end m-1 border border-dark border-opacity-10", :"data-colour" => colour_value, :title => t("browse.tag_details.colour_preview", :colour_value => colour_value)) + colour_value else - safe_join(value.split(";").map { |x| linkify(h(x)) }, ";") + safe_join(value.split(";", -1).map { |x| linkify(h(x)) }, ";") end end diff --git a/test/helpers/browse_tags_helper_test.rb b/test/helpers/browse_tags_helper_test.rb index 0af0d9310..0786af61d 100644 --- a/test/helpers/browse_tags_helper_test.rb +++ b/test/helpers/browse_tags_helper_test.rb @@ -22,6 +22,12 @@ class BrowseTagsHelperTest < ActionView::TestCase html = format_value("unknown", "unknown") assert_dom_equal "unknown", html + html = format_value("unknown", "abc;def") + assert_dom_equal "abc;def", html + + html = format_value("unknown", "foo;") + assert_dom_equal "foo;", html + html = format_value("addr:street", "Rue de l'Amigo") assert_dom_equal "Rue de l'Amigo", html -- 2.39.5