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

fix(isExternal): url parameter can be an internal link #123

Closed
wants to merge 1 commit into from

Conversation

curbengh
Copy link
Contributor

@curbengh curbengh commented Nov 8, 2019

I just noticed a silent issue.

const data = urlObj(url);
const host = data.hostname;

data will be a string when url is an internal link, resulting in host being assigned as undefined. when it is "undefined", it won't be used, thanks to

if (!sitehost || typeof data === 'string') return false;

While current code won't cause any crash, it's a bit unsafe to leave it "undefined" and also could lead to incorrect assumption that data is always a URL object.

@curbengh curbengh requested a review from a team November 8, 2019 01:23
@coveralls
Copy link

Coverage Status

Coverage remained the same at 95.455% when pulling 9dfc53d on curbengh:host-object into 71bbcc4 on hexojs:master.

@SukkaW
Copy link
Member

SukkaW commented Nov 8, 2019

Might have a look at hexojs/hexo#3839 ? In this PR I bring up a poc on performance. In that PR I also fix this issue by moving const host = data.hostname;.

@curbengh
Copy link
Contributor Author

curbengh commented Nov 9, 2019

#124

@curbengh curbengh closed this Nov 9, 2019
@curbengh curbengh deleted the host-object branch November 9, 2019 03:28
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