From: Tom Hughes Date: Sun, 2 Feb 2025 10:32:48 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/5588' X-Git-Tag: live~64 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/5f7dd9d8b378ee532e29f6b49fc745cf9b949e5b?hp=f8ad4c79a4c1880370a035be0c0286a9b4285a69 Merge remote-tracking branch 'upstream/pull/5588' --- diff --git a/app/helpers/social_share_button_helper.rb b/app/helpers/social_share_button_helper.rb index da49347c3..13a9f9e9e 100644 --- a/app/helpers/social_share_button_helper.rb +++ b/app/helpers/social_share_button_helper.rb @@ -35,8 +35,8 @@ module SocialShareButtonHelper def generate_share_url(site, title, url) site = site.to_sym - title = URI.encode_www_form_component(title) - url = URI.encode_www_form_component(url) + title = URI.encode_uri_component(title) + url = URI.encode_uri_component(url) case site when :email diff --git a/test/helpers/social_share_button_helper_test.rb b/test/helpers/social_share_button_helper_test.rb index 136298381..0634632b8 100644 --- a/test/helpers/social_share_button_helper_test.rb +++ b/test/helpers/social_share_button_helper_test.rb @@ -9,9 +9,14 @@ class SocialShareButtonHelperTest < ActionView::TestCase SOCIAL_SHARE_CONFIG.each_value do |icon| assert_dom buttons_dom, "div:has(a img[src='/images/#{icon}'])", :count => 1 do - assert_dom "a[href*='Test+Title']" + assert_dom "a[href*='Test%20Title']" assert_dom "a[href*='https%3A%2F%2Fexample.com']" end end end + + def test_generate_share_url_email + url = generate_share_url(:email, "Diary Entry Title", "https://osm.example.com/some/diary/entry") + assert_equal "mailto:?subject=Diary%20Entry%20Title&body=https%3A%2F%2Fosm.example.com%2Fsome%2Fdiary%2Fentry", url + end end