New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Page#dir: ensure it ends in a slash #4403
Conversation
def _new(url)
return url if url.end_with?("/") || url == "/"
url = File.dirname(url)
url == "/" ? url : "#{url}/"
end
You can edge out more performance with |
👍 for @envygeeks' function. Though I think the |
@alfredxing it could be, but it's slower. |
OK! But (just a sanity check) doesn't the first part ( |
It should but sadly the code ran faster with a more direct check, in there too. I'll double check the benches again just to make sure, because you should and probably are right. |
Ok, I just pushed up another iteration. A bit longer, but doing every little thing helped:
|
8745b8c
to
9daebe8
Compare
@jekyllbot: merge +bug |
Fixes #3974.
/cc @envygeeks, because I'm sure you have a faster/more elegant/more performant solution for this problem.
/cc @jekyll/core for review!