From f0222a3307f3d9d72eb7a68f2927c0e385d6ef93 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Sun, 22 Mar 2020 12:50:41 +0530 Subject: [PATCH] Reduce Pathname objects from front matter defaults --- lib/jekyll/frontmatter_defaults.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/jekyll/frontmatter_defaults.rb b/lib/jekyll/frontmatter_defaults.rb index 21e3cc6faf1..a7d7975cf84 100644 --- a/lib/jekyll/frontmatter_defaults.rb +++ b/lib/jekyll/frontmatter_defaults.rb @@ -103,15 +103,15 @@ def applies?(scope, path, type) end def applies_path?(scope, path) - return true if !scope.key?("path") || scope["path"].empty? + rel_scope_path = scope["path"] + return true if !rel_scope_path.is_a?(String) || rel_scope_path.empty? - sanitized_path = Pathname.new(sanitize_path(path)) - rel_scope_path = Pathname.new(scope["path"]) + sanitized_path = sanitize_path(path) - if scope["path"].to_s.include?("*") + if rel_scope_path.include?("*") glob_scope(sanitized_path, rel_scope_path) else - path_is_subpath?(sanitized_path, strip_collections_dir(scope["path"])) + path_is_subpath?(sanitized_path, strip_collections_dir(rel_scope_path)) end end @@ -134,11 +134,7 @@ def glob_cache(path) end def path_is_subpath?(path, parent_path) - path.ascend do |ascended_path| - return true if ascended_path.to_s == parent_path.to_s - end - - false + path.start_with?(parent_path) end def strip_collections_dir(path)