Skip to content
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

perf: utilize legacy url.parse() in url_for() & full_url_for() #125

Merged
merged 4 commits into from Nov 10, 2019

Conversation

@curbengh
Copy link
Contributor

curbengh commented Nov 9, 2019

Continuation of #124

Ref: hexojs/hexo#3846

curbengh added 2 commits Nov 9, 2019
@curbengh curbengh requested a review from hexojs/core Nov 9, 2019
@coveralls

This comment has been minimized.

Copy link

coveralls commented Nov 9, 2019

Coverage Status

Coverage decreased (-0.06%) to 95.395% when pulling bd99335 on curbengh:refactor-url-api into 71bbcc4 on hexojs:master.

@curbengh

This comment has been minimized.

Copy link
Contributor Author

curbengh commented Nov 9, 2019

if (data.hostname && data.hostname !== sitehost) return path;

if (data.hostname) seems redundant, but it is necessary because new URL('path:withSemicolon', http://${siteHost}).hostname results in empty string ''. Adding that condition is avoid early exit and force it to process path with semicolon.

@SukkaW

This comment has been minimized.

Copy link
Member

SukkaW commented Nov 9, 2019

I notice config.url is added to the test case. So is it means after this PR we might not be able to handle undefined case? For isExternalLink(), it will return false when (!config.url) is true.

@curbengh

This comment has been minimized.

Copy link
Contributor Author

curbengh commented Nov 9, 2019

Good point, now that I think about it, it's more accurate to throw an error if config.url is undefined/null, since full_url_for() and isExternal() wouldn't work.

test/full_url_for.spec.js Outdated Show resolved Hide resolved
lib/full_url_for.js Outdated Show resolved Hide resolved
lib/url_for.js Outdated Show resolved Hide resolved
lib/url_for.js Show resolved Hide resolved
@SukkaW
SukkaW approved these changes Nov 10, 2019
@curbengh curbengh merged commit 71fce3f into hexojs:master Nov 10, 2019
2 of 3 checks passed
2 of 3 checks passed
coverage/coveralls Coverage decreased (-0.06%) to 95.395%
Details
Travis CI - Pull Request Build Passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@curbengh curbengh deleted the curbengh:refactor-url-api branch Nov 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.