A platform for community discussion. Free, open, simple.
FIX: Do not truncate encoded slugs
Rafael dos Santos Silva2304dcf993f6
diff --git a/lib/slug.rb b/lib/slug.rbindex 8436f74ebce..f50492bddfd 100644--- a/lib/slug.rb+++ b/lib/slug.rb@@ -9,6 +9,10 @@ module Slugdef self.for(string, default = 'topic', max_length = MAX_LENGTH)string = string.gsub(/:([\w\-+]+(?::t\d)?):/, '') if string.present? # strip emoji strings+ if SiteSetting.slug_generation_method == 'encoded'+ max_length = 9999 # do not truncate encoded slugs+ end+slug =case (SiteSetting.slug_generation_method || :ascii).to_symwhen :ascii then self.ascii_generator(string)diff --git a/spec/components/slug_spec.rb b/spec/components/slug_spec.rbindex dba8bcb6f57..699d3e0c6b2 100644--- a/spec/components/slug_spec.rb+++ b/spec/components/slug_spec.rb@@ -81,6 +81,11 @@ describe Slug doit "kills the trailing dash" doexpect(Slug.for("2- -this!~-_|,we-#-=^-")).to eq('2-this-we')end++ it "returns a slug that can be used in a valid URL" do+ slug = Slug.for("Γνωμη για αγορα μπουζουκιου μεσω ιντερνετ και εκτίμηση")+ expect { URI.parse("http://example.com/#{slug}") }.not_to raise_error+ endendcontext 'none generator' do