-
Notifications
You must be signed in to change notification settings - Fork 621
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(path/unstable): support URL
input in dirname()
#5747
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5747 +/- ##
==========================================
- Coverage 96.28% 96.27% -0.01%
==========================================
Files 474 474
Lines 38383 38391 +8
Branches 5578 5584 +6
==========================================
+ Hits 36957 36962 +5
- Misses 1384 1387 +3
Partials 42 42 ☔ View full report in Codecov by Sentry. |
URL
input in dirname()
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 once assertThrows()
comments are addressed.
This PR does make me think; what if someone does want to get the parent path of a HTTP URL? E.g. I want to get /documents
from https://example.com/documents/image.png
. How do I do that? Is that regarded as the directory in a HTTP URL? I think it's a valid use case and we should cater to it.
|
Sorry, I want to understand; is there a reason for only allowing
I think your example should work without having to call |
If we simply allow http urls, what happens with the call like |
We could throw, return |
http URLs are not paths while file URLs are equivalent of paths. I think that kind of handling is out of scope of |
part of #5537
This PR adds
dirname(url: URL): string
overload to dirname function.If a user have a file URL string or object, currently they need to convert it to a path string first to perform path operation on it:
This change makes it simpler by automatically interpret the file URL as path