Reduce string allocations from the `link` tag (#8387)

Merge pull request 8387
This commit is contained in:
Ashwin Maroli 2020-09-11 18:54:25 +05:30 committed by GitHub
parent 959fc18db5
commit 51bb40913b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -21,11 +21,12 @@ module Jekyll
@context = context
site = context.registers[:site]
relative_path = Liquid::Template.parse(@relative_path).render(context)
relative_path_with_leading_slash = PathManager.join("", relative_path)
site.each_site_file do |item|
return relative_url(item) if item.relative_path == relative_path
# This takes care of the case for static files that have a leading /
return relative_url(item) if item.relative_path == "/#{relative_path}"
return relative_url(item) if item.relative_path == relative_path_with_leading_slash
end
raise ArgumentError, <<~MSG