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 curbengh commented Nov 9, 2019

Continuation of #124

Ref: hexojs/hexo#3846

@curbengh curbengh requested a review from a team November 9, 2019 04:37
@coveralls
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
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
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
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
@curbengh curbengh merged commit 71fce3f into hexojs:master Nov 10, 2019
@curbengh curbengh deleted the refactor-url-api branch November 10, 2019 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants