-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
file.path.abspath('~foobar') incorrectly maps ~foobar to $HOME/foobar instead of the expected /home/foobar.
One suggestion would be to check to see if an unescaped ~ is present in provided path and then check if there are no filesystem path delimiters:
function abspath(path) {
if (path.match(/\//) === null && path.match(/\\~/) === null) {
/* path probably refers to a user's home directory */
} else {
/* path probably doesn't refer to a user's home directory */
}
});Or you could try something like this, assuming you can find a reliable means of getting user x's $HOME:
a = '~<USER>';
b = '\\~<USER>';
a.replace(/~.*/, <USERS HOME>) === <USERS HOME>
// true
b.replace(/~.*/, <USERS HOME>) === <USERS HOME>
// false
/* only works if USER is `foobar` */
a = '~foobar';
b = '\\~foobar';
a.replace(/~.*/, process.env.HOME) === process.env.HOME
// true
b.replace(/~.*/, process.env.HOME) === process.env.HOME
// falseor something like that.
Metadata
Metadata
Assignees
Labels
No labels