feat(isUrl): urls with empty user#1833
Merged
profnandaa merged 3 commits intovalidatorjs:masterfrom Oct 30, 2021
Merged
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.
|
getlarge
reviewed
Oct 28, 2021
src/lib/isURL.js
Outdated
Comment on lines
117
to
121
| 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.
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;
}
profnandaa
approved these changes
Oct 30, 2021
Member
profnandaa
left a comment
There was a problem hiding this comment.
LGTM, thanks for your contrib! 🎉
theteladras
pushed a commit
to theteladras/validator.js
that referenced
this pull request
Oct 30, 2021
* allow urls with empty user * use array extract * reuse auth split
profnandaa
pushed a commit
that referenced
this pull request
Oct 31, 2021
* allow urls with empty user * use array extract * reuse auth split
profnandaa
pushed a commit
that referenced
this pull request
Oct 31, 2021
* allow urls with empty user * use array extract * reuse auth split
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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