Reduce Pathname objects from front matter defaults (#8067)

Merge pull request 8067
This commit is contained in:
Ashwin Maroli 2020-03-29 22:10:28 +05:30 committed by GitHub
parent 7860d1bac0
commit e972065325
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 10 deletions

View File

@ -103,15 +103,15 @@ module Jekyll
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 @@ module Jekyll
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)