Optimize path sanitization of default front matter (#8154)
Merge pull request 8154
This commit is contained in:
parent
dc8f57d412
commit
eb2423c6c4
|
@ -226,15 +226,14 @@ module Jekyll
|
||||||
end.compact
|
end.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sanitizes the given path by removing a leading and adding a trailing slash
|
# Sanitizes the given path by removing a leading slash
|
||||||
|
|
||||||
SANITIZATION_REGEX = %r!\A/|(?<=[^/])\z!.freeze
|
|
||||||
|
|
||||||
def sanitize_path(path)
|
def sanitize_path(path)
|
||||||
if path.nil? || path.empty?
|
if path.nil? || path.empty?
|
||||||
""
|
""
|
||||||
|
elsif path.start_with?("/")
|
||||||
|
path.gsub(%r!\A/|(?<=[^/])\z!, "")
|
||||||
else
|
else
|
||||||
path.gsub(SANITIZATION_REGEX, "")
|
path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue