Skip to content

Commit

Permalink
Switch slugify regex to support more Unicode character groups (#8167)
Browse files Browse the repository at this point in the history
Merge pull request 8167
  • Loading branch information
matt swanson committed May 14, 2020
1 parent 11dd893 commit f8286b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/jekyll/utils.rb
Expand Up @@ -13,8 +13,8 @@ module Utils
# Constants for use in #slugify
SLUGIFY_MODES = %w(raw default pretty ascii latin).freeze
SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
SLUGIFY_DEFAULT_REGEXP = Regexp.new("[^[:alnum:]]+").freeze
SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze
SLUGIFY_DEFAULT_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}]+").freeze
SLUGIFY_PRETTY_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}._~!$&'()+,;=@]+").freeze
SLUGIFY_ASCII_REGEXP = Regexp.new("[^[A-Za-z0-9]]+").freeze

# Takes a slug and turns it into a simple title.
Expand Down
5 changes: 5 additions & 0 deletions test/test_utils.rb
Expand Up @@ -176,6 +176,11 @@ class TestUtils < JekyllUnitTest
assert_equal "5時-6時-三-一四", Utils.slugify("5時〜6時 三・一四")
end

should "not replace Unicode 'Mark', 'Letter', or 'Number: Decimal Digit' category characters" do
assert_equal "மல்லிப்பூ-வகைகள்", Utils.slugify("மல்லிப்பூ வகைகள்")
assert_equal "மல்லிப்பூ-வகைகள்", Utils.slugify("மல்லிப்பூ வகைகள்", :mode => "pretty")
end

should "not modify the original string" do
title = "Quick-start guide"
Utils.slugify(title)
Expand Down

0 comments on commit f8286b6

Please sign in to comment.