mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 03:03:37 +08:00
FIX: strip emoji string from slug
This commit is contained in:
parent
ec7448bd1b
commit
3566c6f02b
|
@ -6,6 +6,8 @@ module Slug
|
||||||
MAX_LENGTH = 255
|
MAX_LENGTH = 255
|
||||||
|
|
||||||
def self.for(string, default = 'topic', max_length = MAX_LENGTH)
|
def self.for(string, default = 'topic', max_length = MAX_LENGTH)
|
||||||
|
string = string.gsub(/:([\w\-+]+(?::t\d)?):/, '') if string.present? # strip emoji strings
|
||||||
|
|
||||||
slug =
|
slug =
|
||||||
case (SiteSetting.slug_generation_method || :ascii).to_sym
|
case (SiteSetting.slug_generation_method || :ascii).to_sym
|
||||||
when :ascii then self.ascii_generator(string)
|
when :ascii then self.ascii_generator(string)
|
||||||
|
|
|
@ -24,6 +24,10 @@ describe Slug do
|
||||||
expect(Slug.for("o_o_o")).to eq("o-o-o")
|
expect(Slug.for("o_o_o")).to eq("o-o-o")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'strips emoji string' do
|
||||||
|
expect(Slug.for(":smile: To Infinity and beyond! 🚀 :woman:t5:")).to eq("to-infinity-and-beyond")
|
||||||
|
end
|
||||||
|
|
||||||
context 'ascii generator' do
|
context 'ascii generator' do
|
||||||
before { SiteSetting.slug_generation_method = 'ascii' }
|
before { SiteSetting.slug_generation_method = 'ascii' }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user