MCPcopy
hub / github.com/vitejs/vite / supportRelativeURL

Function supportRelativeURL

packages/vite/src/module-runner/sourcemap/interceptor.ts:90–102  ·  view source on GitHub ↗
(file: string, url: string)

Source from the content-addressed store, hash-verified

88
89// Support URLs relative to a directory, but be careful about a protocol prefix
90function supportRelativeURL(file: string, url: string) {
91 if (!file) return url
92 const dir = posixDirname(slash(file))
93 const match = /^\w+:\/\/[^/]*/.exec(dir)
94 let protocol = match ? match[0] : ''
95 const startPath = dir.slice(protocol.length)
96 if (protocol && /^\/\w:/.test(startPath)) {
97 // handle file:///C:/ paths
98 protocol += '/'
99 return protocol + slash(posixResolve(startPath, url))
100 }
101 return protocol + posixResolve(startPath, url)
102}
103
104function getRunnerSourceMap(position: OriginalMapping): CachedMapEntry | null {
105 for (const moduleGraph of evaluatedModulesCache) {

Callers 2

retrieveSourceMapFunction · 0.85
mapSourcePositionFunction · 0.85

Calls 1

slashFunction · 0.90

Tested by

no test coverage detected