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

path.join should handle protocol with double slashes #178

Closed
cossssmin opened this issue Jul 13, 2024 · 2 comments · Fixed by #196
Closed

path.join should handle protocol with double slashes #178

cossssmin opened this issue Jul 13, 2024 · 2 comments · Fixed by #196
Labels
bug Something isn't working

Comments

@cossssmin
Copy link

Environment

pathe v1.1.2

Node.js v20.10.0, Windows 11

Reproduction

$ node
Welcome to Node.js v20.10.0.
Type ".help" for more information.
> const pe = require('pathe')
undefined
> pe.join('https://example.com', 'image.png')
'https:/example.com/image.png'
> const path = require('node:path')
undefined
> path.join('https://example.com', 'image.png')
'https:\\example.com\\image.png'
>

Describe the bug

When using join with a URL, the double // is reduced to a single /:

- https://example.com
+ https:/example.com

Additional context

No response

Logs

No response

@cossssmin cossssmin added the bug Something isn't working label Jul 13, 2024
@pi0 pi0 changed the title path.join() with absolute and relative paths path.join should handle protocol with double slashes Jul 16, 2024
@ToshB
Copy link

ToshB commented Sep 4, 2024

I encountered a similar case with UNC paths, where it seems like the deduplication of forward slashes also break UNC paths in a similar way.
It works the first time, but after the leading slashes have been normalized, consequent calls to join replace them with a single slash.

const initialPath = '\\\\uncpath\\share';
const normalizedPath = pe.join(initialPath, 'subfolder'); // //uncpath/share/subfolder
const mangledPath = pe.join(normalizedPath, 'file.txt'); // /uncpath/share/subfolder/file.txt

@pi0
Copy link
Member

pi0 commented Jan 3, 2025

Testing locally, original reproduction is ONLY valid on windows, path.join('https://example.com', 'image.png') on POSIX, returns https:/example.com/image.png in Node 22.12. (path utils are not URL utils..)

The second issue with UNC, is valid through (using path.win32. API only).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants