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