Skip to content

Commit 958f95d

Browse files
committed
Fix handling of file:/// paths on *nix systems
1 parent 3bd9b4b commit 958f95d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

source-map-support.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ retrieveFileHandlers.push(function(path) {
6666
path = path.trim();
6767
if (/^file:/.test(path)) {
6868
// existsSync/readFileSync can't handle file protocol, but once stripped, it works
69-
path = path.replace(/file:\/\/(\w:\\|\/)/, '');
69+
path = path.replace(/file:\/\/\/(\w:)?/, function(protocol, drive) {
70+
return drive ?
71+
'' : // file:///C:/dir/file -> C:/dir/file
72+
'/'; // file:///root-dir/file -> /root-dir/file
73+
});
7074
}
7175
if (path in fileContentsCache) {
7276
return fileContentsCache[path];

0 commit comments

Comments
 (0)