Collapse gsub

This commit is contained in:
Pat Hawks 2016-10-18 18:53:54 -05:00
parent 53d20bc77e
commit c4a23b4ced
No known key found for this signature in database
GPG Key ID: F1746FF5F18B3D1B
2 changed files with 2 additions and 3 deletions

View File

@ -188,7 +188,7 @@ module Jekyll
if path.nil? || path.empty? if path.nil? || path.empty?
"" ""
else else
path.gsub(%r!\A/!, "").gsub(%r!([^/])\z!, '\1') path.gsub(%r!\A/|(?<=[^/])\z!, "".freeze)
end end
end end
end end

View File

@ -62,8 +62,7 @@ module Jekyll
end end
def sanitize_filename(name) def sanitize_filename(name)
name.gsub!(%r![^\w\s-]+!, "") name.gsub!(%r![^\w\s-]+|(?<=^|\b\s)\s+(?=$|\s?\b)!, "".freeze)
name.gsub!(%r!(^|\b\s)\s+($|\s?\b)!, '\\1\\2')
name.gsub(%r!\s+!, "_") name.gsub(%r!\s+!, "_")
end end
end end