|
1 | 1 | const { TraceMap, originalPositionFor, AnyMap } = require('@jridgewell/trace-mapping');
|
| 2 | +const resolveUri = require('@jridgewell/resolve-uri'); |
2 | 3 | var path = require('path');
|
3 | 4 | const { fileURLToPath } = require('url');
|
4 | 5 | var util = require('util');
|
@@ -187,23 +188,7 @@ sharedData.internalRetrieveFileHandlers.push(function(path) {
|
187 | 188 | // Support URLs relative to a directory, but be careful about a protocol prefix
|
188 | 189 | // in case we are in the browser (i.e. directories may start with "http://" or "file:///")
|
189 | 190 | function supportRelativeURL(file, url) {
|
190 |
| - if (!file) return url; |
191 |
| - let targetPath = url; |
192 |
| - try { |
193 |
| - const urlParsed = new URL(url); |
194 |
| - if(urlParsed.protocol !== 'file:') return url; |
195 |
| - targetPath = fileURLToPath(urlParsed); |
196 |
| - } catch(e) {} |
197 |
| - var dir = path.dirname(file); |
198 |
| - var match = /^\w+:\/\/[^\/]*/.exec(dir); |
199 |
| - var protocol = match ? match[0] : ''; |
200 |
| - var startPath = dir.slice(protocol.length); |
201 |
| - if (protocol && /^\/\w\:/.test(startPath)) { |
202 |
| - // handle file:///C:/ paths |
203 |
| - protocol += '/'; |
204 |
| - return protocol + path.resolve(dir.slice(protocol.length), targetPath).replace(/\\/g, '/'); |
205 |
| - } |
206 |
| - return protocol + path.resolve(dir.slice(protocol.length), targetPath); |
| 191 | + return resolveUri(url, file); |
207 | 192 | }
|
208 | 193 |
|
209 | 194 | function retrieveSourceMapURL(source) {
|
|
0 commit comments