From 36dc8c21698b853a08cb4e0c3927b04c55f67b1d Mon Sep 17 00:00:00 2001 From: Jussi Kinnula Date: Fri, 18 Mar 2016 11:13:06 +0200 Subject: [PATCH] Add urlsafe method for slugify --- lib/jekyll/utils.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index 179981ec..5140dc52 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -10,6 +10,7 @@ module Jekyll SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze SLUGIFY_DEFAULT_REGEXP = Regexp.new('[^[:alnum:]]+').freeze SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze + SLUGIFY_URLSAFE_REGEXP = Regexp.new("[^[A-Za-z0-9]]+").freeze # Takes an indented string and removes the preceding spaces on each line @@ -190,6 +191,11 @@ module Jekyll # "._~!$&'()+,;=@" is human readable (not URI-escaped) in URL # and is allowed in both extN and NTFS. SLUGIFY_PRETTY_REGEXP + when 'urlsafe' + # For web servers not being able to handle Unicode, the safe + # method is to ditch anything else but latin letters and numeric + # digits. + SLUGIFY_URLSAFE_REGEXP end # Strip according to the mode