-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(isUrl): urls with empty user #1833
feat(isUrl): urls with empty user #1833
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1833 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 102 102
Lines 2029 2032 +3
Branches 457 458 +1
=========================================
+ Hits 2029 2032 +3
Continue to review full report at Codecov.
|
src/lib/isURL.js
Outdated
const user_password = split[0].split(':'); | ||
if (user_password[0] === '' && user_password[1] === '') { | ||
return false; | ||
} | ||
auth = split.shift(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or like this :)
auth = split.shift();
if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
return false;
}
const [user, password] = auth.split(':');
if (user === '' && password === '') {
return false;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for your contrib! 🎉
* allow urls with empty user * use array extract * reuse auth split
* allow urls with empty user * use array extract * reuse auth split
* allow urls with empty user * use array extract * reuse auth split
URL with an empty user are valid.
Example:
This kind of URL (${protocol}://:${password}@${hostname}:${port}) can be parsed and allows to extract the password.
discussion: #1681
Checklist