Skip to content

Commit

Permalink
Optimize path sanitization of default front matter (#8154)
Browse files Browse the repository at this point in the history
Merge pull request 8154
  • Loading branch information
ashmaroli committed May 10, 2020
1 parent dc8f57d commit eb2423c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/jekyll/frontmatter_defaults.rb
Expand Up @@ -226,15 +226,14 @@ def valid_sets
end.compact
end

# Sanitizes the given path by removing a leading and adding a trailing slash

SANITIZATION_REGEX = %r!\A/|(?<=[^/])\z!.freeze

# Sanitizes the given path by removing a leading slash
def sanitize_path(path)
if path.nil? || path.empty?
""
elsif path.start_with?("/")
path.gsub(%r!\A/|(?<=[^/])\z!, "")
else
path.gsub(SANITIZATION_REGEX, "")
path
end
end
end
Expand Down

0 comments on commit eb2423c

Please sign in to comment.