-
Notifications
You must be signed in to change notification settings - Fork 42
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(hasProtocol): optionally allow protocol relative url #16
Conversation
Happy to flip default or disable |
README.md
Outdated
// Result: false | ||
isURL('/') | ||
// Result: true | ||
isURL('//', true) |
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.
//
is not really a valid URL even considering scheme is optional since has no path:
URI = scheme:[//authority]path[?query][#fragment]
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.
Trying in chrome, <a href="//>
redirects to about:blank#blocked
(or any pattern like ///
)
Codecov Report
@@ Coverage Diff @@
## main #16 +/- ##
==========================================
+ Coverage 86.91% 87.03% +0.12%
==========================================
Files 7 7
Lines 214 216 +2
Branches 60 62 +2
==========================================
+ Hits 186 188 +2
Misses 28 28
Continue to review full report at Codecov.
|
@danielroe More I'm thinking isURL, should do real URL validation rather than checking protocol existence. Something like What do you think if in this PR:
And move isURL task to new PR with proper regex (or parser based on perf and complexity)? |
@pi0 Sounds like a good plan. I'll make a stab. (Separate comment) I wonder about differentiating utils that parse/validate input in accordance with spec compliance vs 'cheap' utils that assume pre validation. |
@danielroe Agree for naming. hasProtocol since even it is a cheap implementation, it's name is clear it is not validating entire URL. BTW generally, there is not single standard for URL to follow and this PR is an example about conventions that are supported. (another example plus as space encoding) |
…rt to `hasProtocol`
isURL
utility and parse urls without protocolhasProtocol
and in URL functions
hasProtocol
and in URL functions
No description provided.