11import convertPathToPosix from "./convert-path-to-posix" ;
2- import path , { win32 } from "path" ;
3-
2+ import path from "path" ;
43const forwardSlashPattern = / \/ / g;
54const protocolPattern = / ^ ( \w { 2 , } ) : \/ \/ / i;
65const jsonPointerSlash = / ~ 1 / g;
@@ -9,7 +8,6 @@ const jsonPointerTilde = /~0/g;
98import { join } from "path" ;
109import { isWindows } from "./is-windows" ;
1110
12- const projectDir = join ( __dirname , ".." , ".." ) ;
1311// RegExp patterns to URL-encode special characters in local filesystem paths
1412const urlEncodePatterns = [ / \? / g, "%3F" , / # / g, "%23" ] ;
1513
@@ -183,12 +181,13 @@ export function fromFileSystemPath(path: any) {
183181 // Step 1: On Windows, replace backslashes with forward slashes,
184182 // rather than encoding them as "%5C"
185183 if ( isWindows ( ) ) {
184+ const projectDir = join ( __dirname , ".." , ".." ) ;
186185 const upperPath = path . toUpperCase ( ) ;
187186 const projectDirPosixPath = convertPathToPosix ( projectDir ) ;
188187 const posixUpper = projectDirPosixPath . toUpperCase ( ) ;
189188 const hasProjectDir = upperPath . includes ( posixUpper ) ;
190189 const hasProjectUri = upperPath . includes ( posixUpper ) ;
191- const isAbsolutePath = win32 . isAbsolute ( path ) ;
190+ const isAbsolutePath = path ?. win32 ? .isAbsolute ( path ) ;
192191
193192 if ( ! ( hasProjectDir || hasProjectUri || isAbsolutePath ) ) {
194193 path = join ( projectDir , path ) ;
0 commit comments