Skip to content
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 in first arg of join() #5863

Merged
merged 4 commits into from
Aug 30, 2024

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Aug 29, 2024

part of #5537

This PR adds support of URL as the first parameter of join

@github-actions github-actions bot added the path label Aug 29, 2024
Copy link

codecov bot commented Aug 29, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.34%. Comparing base (745c4a6) to head (97942c1).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
path/join.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5863      +/-   ##
==========================================
+ Coverage   96.26%   96.34%   +0.07%     
==========================================
  Files         479      479              
  Lines       38705    38674      -31     
  Branches     5617     5631      +14     
==========================================
+ Hits        37259    37260       +1     
+ Misses       1403     1370      -33     
- Partials       43       44       +1     

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

@kt3k kt3k changed the title Support url in join feat(path/unstable): support URL in first arg of join Aug 29, 2024
@kt3k kt3k changed the title feat(path/unstable): support URL in first arg of join feat(path/unstable): support URL in first arg of join Aug 29, 2024
path/join.ts Outdated Show resolved Hide resolved

// URLs
[[new URL("file:///"), "x/b", "..", "/b/c.js"], "/x/b/c.js"],
[[new URL("file:///foo"), "../../../bar"], "/bar"],
Copy link
Contributor

Choose a reason for hiding this comment

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

The first test case looks good. But I'd expect the result of the 2nd test case to be "/../../bar".

Copy link
Member Author

Choose a reason for hiding this comment

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

/bar is the normalized form of /../../bar. There's no parent directory of the root directory

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I tested with node:path and that does appear to be the case. That doesn't really make sense to me but I guess is fine 🤷🏾‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

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

How did you test it? The below prints /bar both in Node.js and Deno

import { join } from "node:path";
console.log(join("/foo", "../../../bar"));

BTW join("file:///foo", "../../../bar") becomes ../bar because "file:///foo" is considered relative path file:/bar (file: part is considered as directory name instead of scheme name)

path/posix/join.ts Outdated Show resolved Hide resolved
path/windows/join.ts Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Current tests seem a little bare. Could we please add the tests from the examples?

@iuioiua iuioiua changed the title feat(path/unstable): support URL in first arg of join feat(path/unstable): support URL in first arg of join() Aug 30, 2024
@kt3k kt3k merged commit 94a7e1b into denoland:main Aug 30, 2024
16 checks passed
@kt3k kt3k deleted the support-url-in-join branch August 30, 2024 04:18
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