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

Add ability to handle win32 relative paths #401

Open
davakh opened this issue Jan 3, 2024 · 4 comments · May be fixed by #402
Open

Add ability to handle win32 relative paths #401

davakh opened this issue Jan 3, 2024 · 4 comments · May be fixed by #402

Comments

@davakh
Copy link

davakh commented Jan 3, 2024

Issue

Right now, based on codebase, library supports only posix relative paths.

Reproduction

This is correct relative path in context of this library:

../../../src

This is incorrect relative path in context of this library:

..\\..\\..\\src

To understand how the library understands these paths, you can call getType from this file:
posix path as Relative; win32 path - as Normal

So, anything that can be passed as a result by path.relative(...) in Node.js, will not work as expected on Windows machines.

Solutions

Possible solution is to add separation in the enum of types for RelativePosix and RelativeWin, like for the Absolute.. paths. But it's hard to predict what integrations with this library are going to break, so I think it can be a big deal.

Workaround

Add replacing for backward compatibility with Windows (Windows can handle posix separator):

path.relative(....).split(path.win32.sep).join(path.posix.sep);

PS. Maybe you want to handle only relative posix paths in this library, and then I think it would be cool to add information about this scenario or to close this issue with a preferable workaround.

@alexander-akait
Copy link
Member

Hello, can you provide a problem/example where you got such paths?

@davakh
Copy link
Author

davakh commented Jan 5, 2024

It's possible to get this type of paths when you work with module-federation f.e. Of course, it's overhead to give an example with another library, but I can provide an example with current library via codesandbox.

@alexander-akait
Copy link
Member

@davakh Sorry for delay, do you want to send a PR?

@davakh
Copy link
Author

davakh commented Jan 22, 2024

Yes, I have some thoughts on how to solve it. I'll try to give a PR in near future.

@alexander-akait alexander-akait linked a pull request Feb 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Priority - Medium
Development

Successfully merging a pull request may close this issue.

2 participants