-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
node-api: preserve URL filenames without conversion #58578
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
base: main
Are you sure you want to change the base?
node-api: preserve URL filenames without conversion #58578
Conversation
Review requested:
|
6b4b308
to
0df3eb0
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #58578 +/- ##
==========================================
- Coverage 90.21% 90.14% -0.07%
==========================================
Files 635 636 +1
Lines 187494 187895 +401
Branches 36838 36879 +41
==========================================
+ Hits 169144 169375 +231
- Misses 11145 11287 +142
- Partials 7205 7233 +28
🚀 New features to boost your workflow:
|
src/node_api.cc
Outdated
// receive it as a URL already. | ||
module_filename = node::url::FromFilePath(filename.ToStringView()); | ||
const auto filename_view = filename.ToStringView(); | ||
if (filename_view.find("://") != std::string_view::npos) { |
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.
This is not a valid way to test whether the input is a URL or not
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.
@addaleax thanks, I wonder if using node::url::URL::Parse()
would be a good solution here
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.
Hello @anonrig
We're trying to improve URL detection in module loading. Currently using:
if (filename_view.find("://") != std::string_view::npos)
Would ada::can_parse(filename_view)
be a better/healthier approach here?
Context: We need to distinguish between file paths and URLs to decide whether to:
- Use the string directly (if URL)
- Convert via
node::url::FromFilePath()
(if file path)
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.
Yes you can use can parse to check if an input is url.
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.
thanks I will use this
allows us to process filenames that are already URLs by passing them unchanged