store regexp in a constant (#6887)

Merge pull request 6887
This commit is contained in:
ashmaroli 2018-04-12 21:07:14 +05:30 committed by jekyllbot
parent 5ba6a36b1f
commit 971815cd5c
1 changed files with 4 additions and 1 deletions

View File

@ -207,11 +207,14 @@ module Jekyll
end end
# Sanitizes the given path by removing a leading and adding a trailing slash # Sanitizes the given path by removing a leading and adding a trailing slash
SANITIZATION_REGEX = %r!\A/|(?<=[^/])\z!
def sanitize_path(path) def sanitize_path(path)
if path.nil? || path.empty? if path.nil? || path.empty?
"" ""
else else
path.gsub(%r!\A/|(?<=[^/])\z!, "".freeze) path.gsub(SANITIZATION_REGEX, "")
end end
end end
end end