1
1
import { describe , it , expect } from "vitest" ;
2
- import { isWindows } from ' std-env'
2
+ import { isWindows } from " std-env" ;
3
3
import {
4
4
isNodeBuiltin ,
5
5
sanitizeFilePath ,
@@ -159,15 +159,17 @@ describe("lookupNodeModuleSubpath", () => {
159
159
} ) ;
160
160
161
161
describe ( "fileURLToPath" , ( ) => {
162
- const tests = isWindows ? [
163
- [ "file:///C:/path/" , "C:/path/" ] ,
164
- [ "file://nas/foo.txt" , "//nas/foo.txt" ] ,
165
- [ "file://C:/你好.txt" , "C:/你好.txt" ] ,
166
- [ "file://C:/hello world" , "C:/hello world" ] ,
167
- ] as const : [
168
- [ "file:///你好.txt" , "/你好.txt" ] ,
169
- [ "file:///hello world" , "/hello world" ] ,
170
- ] as const ;
162
+ const tests = isWindows
163
+ ? ( [
164
+ [ "file:///C:/path/" , "C:/path/" ] ,
165
+ [ "file://nas/foo.txt" , "//nas/foo.txt" ] ,
166
+ [ "file://C:/你好.txt" , "C:/你好.txt" ] ,
167
+ [ "file://C:/hello world" , "C:/hello world" ] ,
168
+ ] as const )
169
+ : ( [
170
+ [ "file:///你好.txt" , "/你好.txt" ] ,
171
+ [ "file:///hello world" , "/hello world" ] ,
172
+ ] as const ) ;
171
173
for ( const [ input , output ] of tests ) {
172
174
it ( `${ input } should resolve to ${ output } ` , ( ) => {
173
175
expect ( fileURLToPath ( input ) ) . toBe ( output ) ;
@@ -176,13 +178,15 @@ describe("fileURLToPath", () => {
176
178
} ) ;
177
179
178
180
describe ( "pathToFileURL" , ( ) => {
179
- const tests = isWindows ? [
180
- [ "/foo#1" , / f i l e : \/ \/ \/ \w : \/ f o o % 2 3 1 / ] ,
181
- [ "/some/path%.c" , / f i l e : \/ \/ \/ \w : \/ s o m e \/ p a t h % 2 5 .c / ] ,
182
- ] as const :[
183
- [ "/foo#1" , "file:///foo%231" ] ,
184
- [ "/some/path%.c" , "file:///some/path%25.c" ] ,
185
- ] as const ;
181
+ const tests = isWindows
182
+ ? ( [
183
+ [ "/foo#1" , / f i l e : \/ \/ \/ \w : \/ f o o % 2 3 1 / ] ,
184
+ [ "/some/path%.c" , / f i l e : \/ { 3 } \w : \/ s o m e \/ p a t h % 2 5 .c / ] ,
185
+ ] as const )
186
+ : ( [
187
+ [ "/foo#1" , "file:///foo%231" ] ,
188
+ [ "/some/path%.c" , "file:///some/path%25.c" ] ,
189
+ ] as const ) ;
186
190
for ( const [ input , output ] of tests ) {
187
191
it ( `${ input } should resolve to ${ output } ` , ( ) => {
188
192
expect ( pathToFileURL ( input ) ) . toMatch ( output ) ;
0 commit comments