-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
355 additions
and
325 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
import tap from 'tap' | ||
import process from 'node:process' | ||
|
||
import { fsPathToUrlPath } from './fs-path-to-url.js' | ||
|
||
const isWin = process.platform === 'win32' | ||
|
||
tap.test('fsPathToUrlPath works for all OS file path types', async (t) => { | ||
const tests = [ | ||
{ | ||
input: '/foo/bar/baz', | ||
input: 'foo/bar/baz', | ||
expect: '/foo/bar/baz', | ||
note: 'unix style paths' | ||
note: 'unix style paths', | ||
winOnly: false | ||
}, | ||
{ | ||
input: '\\foo\\bar\\baz', | ||
input: 'foo\\bar\\baz', | ||
expect: '/foo/bar/baz', | ||
note: 'windows style paths' | ||
note: 'windows style paths', | ||
winOnly: true | ||
} | ||
] | ||
|
||
for (const test of tests) { | ||
t.equal(fsPathToUrlPath(test.input), test.expect, test.note) | ||
if (isWin && test.winOnly) { | ||
t.equal(fsPathToUrlPath(test.input), test.expect, test.note) | ||
} else if (!isWin && !test.winOnly) { | ||
t.equal(fsPathToUrlPath(test.input), test.expect, test.note) | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters