in src/browser/FileProxy.js [722:790]
function resolveToFullPath_ (cwdFullPath, path) {
path = path || '';
let fullPath = path;
let prefix = '';
cwdFullPath = cwdFullPath || DIR_SEPARATOR;
if (cwdFullPath.indexOf(FILESYSTEM_PREFIX) === 0) {
prefix = cwdFullPath.substring(0, cwdFullPath.indexOf(DIR_SEPARATOR, FILESYSTEM_PREFIX.length));
cwdFullPath = cwdFullPath.substring(cwdFullPath.indexOf(DIR_SEPARATOR, FILESYSTEM_PREFIX.length));
}
const relativePath = path[0] !== DIR_SEPARATOR;
if (relativePath) {
fullPath = cwdFullPath;
if (cwdFullPath !== DIR_SEPARATOR) {
fullPath += DIR_SEPARATOR + path;
} else {
fullPath += path;
}
}
// Remove doubled separator substrings
const re = new RegExp(DIR_SEPARATOR + DIR_SEPARATOR, 'g');
fullPath = fullPath.replace(re, DIR_SEPARATOR);
// Adjust '..'s by removing parent directories when '..' flows in path.
const parts = fullPath.split(DIR_SEPARATOR);
for (let i = 0; i < parts.length; ++i) {
const part = parts[i];
if (part === '..') {
parts[i - 1] = '';
parts[i] = '';
}
}
fullPath = parts.filter(function (el) {
return el;
}).join(DIR_SEPARATOR);
// Add back in leading slash.
if (fullPath[0] !== DIR_SEPARATOR) {
fullPath = DIR_SEPARATOR + fullPath;
}
// Replace './' by current dir. ('./one/./two' -> one/two)
fullPath = fullPath.replace(/\.\//g, DIR_SEPARATOR);
// Replace '//' with '/'.
fullPath = fullPath.replace(/\/\//g, DIR_SEPARATOR);
// Replace '/.' with '/'.
fullPath = fullPath.replace(/\/\./g, DIR_SEPARATOR);
// Remove '/' if it appears on the end.
if (fullPath[fullPath.length - 1] === DIR_SEPARATOR &&
fullPath !== DIR_SEPARATOR) {
fullPath = fullPath.substring(0, fullPath.length - 1);
}
let storagePath = prefix + fullPath;
storagePath = decodeURI(storagePath);
fullPath = decodeURI(fullPath);
return {
storagePath,
fullPath,
fileName: fullPath.split(DIR_SEPARATOR).pop(),
fsName: prefix.split(DIR_SEPARATOR).pop()
};
}