123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- var sep = require('path').sep || '/';
- module.exports = fileUriToPath;
- function fileUriToPath (uri) {
- if ('string' != typeof uri ||
- uri.length <= 7 ||
- 'file://' != uri.substring(0, 7)) {
- throw new TypeError('must pass in a file:// URI to convert to a file path');
- }
- var rest = decodeURI(uri.substring(7));
- var firstSlash = rest.indexOf('/');
- var host = rest.substring(0, firstSlash);
- var path = rest.substring(firstSlash + 1);
-
-
-
-
- if ('localhost' == host) host = '';
- if (host) {
- host = sep + sep + host;
- }
-
-
-
-
-
-
-
- path = path.replace(/^(.+)\|/, '$1:');
-
- if (sep == '\\') {
- path = path.replace(/\//g, '\\');
- }
- if (/^.+\:/.test(path)) {
-
- } else {
-
- path = sep + path;
- }
- return host + path;
- }
|