Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
577066850b | ||
|
|
0ec989cf1e |
@@ -89,10 +89,13 @@ ftpServer.listen()
|
||||
- __password__
|
||||
- Password provided in the `PASS` command
|
||||
- Only provided if `anonymous` is set to `false`
|
||||
- __resolve ({fs, cwd, blacklist, whitelist})__
|
||||
- __resolve ({fs, root, cwd, blacklist, whitelist})__
|
||||
- __fs__ _[optional]_
|
||||
- Optional file system class for connection to use
|
||||
- See [File System](#file-system) for implementation details
|
||||
- __root__ _[optional]_
|
||||
- If `fs` not provided, will set the root directory for the connection
|
||||
- The user cannot traverse lower than this directory
|
||||
- __cwd__ _[optional]_
|
||||
- If `fs` not provided, will set the starting directory for the connection
|
||||
- __blacklist__ _[optional]_
|
||||
|
||||
@@ -13,8 +13,8 @@ class FileSystem {
|
||||
cwd = '/'
|
||||
} = {}) {
|
||||
this.connection = connection;
|
||||
this.cwd = cwd;
|
||||
this.root = root;
|
||||
this.cwd = nodePath.resolve(cwd);
|
||||
this.root = nodePath.resolve(root);
|
||||
}
|
||||
|
||||
_resolvePath(path) {
|
||||
@@ -60,7 +60,7 @@ class FileSystem {
|
||||
if (!stat.isDirectory()) throw new errors.FileSystemError('Not a valid directory');
|
||||
})
|
||||
.then(() => {
|
||||
this.cwd = path.replace(new RegExp(`^${this.root}`), '') || '/';
|
||||
this.cwd = path.substring(this.root.length) || '/';
|
||||
return this.currentDirectory();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user