@svrooij/ftpd
Version:
Node FTP Server (reboot)
15 lines (12 loc) • 349 B
JavaScript
const pathModule = require('path');
function withCwd(cwd, path) {
const firstChar = (path || '').charAt(0);
cwd = cwd || pathModule.sep;
path = path || '';
if (firstChar === '/' || firstChar === pathModule.sep) {
cwd = pathModule.sep;
}
path = pathModule.join(pathModule.sep, cwd, path);
return path;
}
module.exports = withCwd;