Skip to content

fix(path): improve Node.js compatibility, run tests in node and bun#7104

Open
kt3k wants to merge 1 commit into
denoland:mainfrom
kt3k:test-path-in-node-bun
Open

fix(path): improve Node.js compatibility, run tests in node and bun#7104
kt3k wants to merge 1 commit into
denoland:mainfrom
kt3k:test-path-in-node-bun

Conversation

@kt3k
Copy link
Copy Markdown
Contributor

@kt3k kt3k commented Apr 24, 2026

This PR adds tests of path in Node and Bun

ref #7103

@github-actions github-actions Bot added the path label Apr 24, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.61%. Comparing base (0796a25) to head (161b494).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7104   +/-   ##
=======================================
  Coverage   94.60%   94.61%           
=======================================
  Files         633      633           
  Lines       51777    51777           
  Branches     9324     9324           
=======================================
+ Hits        48986    48987    +1     
  Misses       2216     2216           
+ Partials      575      574    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread path/posix/to_file_url.ts
const url = new URL("file:///");
url.pathname = encodeWhitespace(
path.replace(/%/g, "%25").replace(/\\/g, "%5C"),
path.replace(/^\/+/, "/").replace(/%/g, "%25").replace(/\\/g, "%5C"),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The below works differently in Deno and Node:

const u = new URL("file:///");
u.pathname = "//foo";
console.log(u.href);
// prints file:///foo in Deno
// prints file:////foo in Node, Bun, and browsers

This change normalizes the differences above (and therefore no breaking changes to deno users)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created an issue in rust-url about the above behavior servo/rust-url#1118

Copy link
Copy Markdown

@lunadogbot lunadogbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path/posix/to_file_url.ts: collapsing leading /+ before assigning url.pathname is the right fix — Deno already produced file:///foo from pathname = "//foo", this aligns Node/Bun to that. Existing posix.toFileUrl("//localhost/...") cases in to_file_url_test.ts cover it. The is_glob worker rewrite is also an improvement — it now assertEquals the three results, where the data-URL version only asserted that postMessage ran.

  • nit: title is test(path) but the to_file_url.ts change is a runtime behaviour tweak, not test-only. fix(path) would be more accurate.

@lunadogbot
Copy link
Copy Markdown

@bartlomieju this is ready to merge

@kt3k kt3k changed the title test(path): run path tests in node and bun fix(path): improve Node.js compatibility, run tests in node and bun May 13, 2026
@kt3k
Copy link
Copy Markdown
Contributor Author

kt3k commented May 13, 2026

nit: title is test(path) but the to_file_url.ts change is a runtime behaviour tweak, not test-only. fix(path) would be more accurate.

updated the title following the above message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants