[plugin cli] Stricter path checking, keeps support for file://

This commit is contained in:
Jonathan Budzenski 2017-01-27 10:04:38 -06:00
parent f47bc1e802
commit 6bb880165a
No known key found for this signature in database
GPG key ID: D28BF9418FA0F292

View file

@ -6,8 +6,9 @@ import { parse } from 'url';
export function _getFilePath(filePath) {
const decodedPath = decodeURI(filePath);
const isWindows = /^win/.test(process.platform);
if (isWindows) {
return decodedPath.replace(/^\//, '');
const prefixedDrive = /^\/[a-zA-Z]:/.test(decodedPath);
if (isWindows && prefixedDrive) {
return decodedPath.slice(1);
}
return decodedPath;
}