Skip to content

Commit 7aaf30b

Browse files
authored
Merge pull request #202 from kriszyp/file-protocol-support2
Fix handling of file:/// paths on *nix systems
2 parents 88008a6 + 958f95d commit 7aaf30b

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)