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

Support all Windows paths #109

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Support all Windows paths #109

wants to merge 4 commits into from

Conversation

jridgewell
Copy link
Owner

@cspotcode: Please try this branch to see if it resolves your issues.

Fixes #108.

@cspotcode
Copy link

Thanks, I appreciate it. I got to a point where tests are passing with the workaround I implemented, and I want to move on to some other things, so it might be a bit before I'm able to test this.

@liuxingbaoyu
Copy link

Hi! Can you merge this PR? I tried to fix babel/babel#15784 based on this.

diff --git a/src/resolve-uri.ts b/src/resolve-uri.ts
index 1a52169..dc952ea 100644
--- a/src/resolve-uri.ts
+++ b/src/resolve-uri.ts
@@ -294,6 +294,7 @@ export default function resolve(input: string, base: string | undefined): string
   const inputIsWindows = isWindowsPath(input);
   const baseIsWindows = !inputIsWindows && !!base && isWindowsPath(base);
   if (!inputIsWindows && !baseIsWindows) return resolveInternal(input, base || '');
+  if (!inputIsWindows && baseIsWindows) input = toWindows(input);
 
   const resolved = resolveInternal(windowsToUrl(input), windowsToUrl(base || ''));
   return toWindows(resolved);
diff --git a/test/with-absolute-Windows-path-base.test.js b/test/with-absolute-Windows-path-base.test.js
index 074dd17..623022d 100644
--- a/test/with-absolute-Windows-path-base.test.js
+++ b/test/with-absolute-Windows-path-base.test.js
@@ -1776,6 +1776,20 @@ describe('with absolute Windows path base', () => {
         const resolved = resolve(input, base);
         assert.strictEqual(resolved, 'C:\\main.js.map');
       });
+
+      it('normalizes mixed `/` and `\\` #babel/15784', () => {
+        const base = 'C:\\root\\dir\\';
+        const input = 'C:/root/dir/main.js.map';
+        const resolved = resolve(input, base);
+        assert.strictEqual(resolved, 'C:\\root\\dir\\main.js.map');
+      });
+
+      it('normalizes mixed `/` and `\\` 2', () => {
+        const base = 'C:/root/dir/\\';
+        const input = 'C:\\root\\dir\\main.js.map';
+        const resolved = resolve(input, base);
+        assert.strictEqual(resolved, 'C:\\root\\dir\\main.js.map');
+      });
     });
 
     describe('with leading dot relative input', () => {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support windows paths on windows, both absolute and relative
3 participants