From 971815cd5cc14b14f74178d1ccf1b21de6eac5d6 Mon Sep 17 00:00:00 2001 From: ashmaroli Date: Thu, 12 Apr 2018 21:07:14 +0530 Subject: [PATCH] store regexp in a constant (#6887) Merge pull request 6887 --- lib/jekyll/frontmatter_defaults.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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