diff --git a/app/models/tag.rb b/app/models/tag.rb index 866adf3fce7..73af70faf1c 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -152,7 +152,7 @@ class Tag < ActiveRecord::Base end def full_url - "#{Discourse.base_url}/tag/#{self.name}" + "#{Discourse.base_url}/tag/#{UrlHelper.encode_component(self.name)}" end def index_search diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index e31b15b8072..ea30571a2c3 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -202,6 +202,14 @@ describe Tag do end end + context "full_url" do + let(:tag) { Fabricate(:tag, name: "🚀") } + + it "percent encodes emojis" do + expect(tag.full_url).to eq("http://test.localhost/tag/%F0%9F%9A%80") + end + end + context "synonyms" do let(:synonym) { Fabricate(:tag, target_tag: tag) }