11import { describe , it , expect } from "vitest" ;
2- import { isWindows } from ' std-env'
2+ import { isWindows } from " std-env" ;
33import {
44 isNodeBuiltin ,
55 sanitizeFilePath ,
@@ -159,15 +159,17 @@ describe("lookupNodeModuleSubpath", () => {
159159} ) ;
160160
161161describe ( "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 ) ;
171173 for ( const [ input , output ] of tests ) {
172174 it ( `${ input } should resolve to ${ output } ` , ( ) => {
173175 expect ( fileURLToPath ( input ) ) . toBe ( output ) ;
@@ -176,13 +178,15 @@ describe("fileURLToPath", () => {
176178} ) ;
177179
178180describe ( "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 ) ;
186190 for ( const [ input , output ] of tests ) {
187191 it ( `${ input } should resolve to ${ output } ` , ( ) => {
188192 expect ( pathToFileURL ( input ) ) . toMatch ( output ) ;
0 commit comments