Skip to content

Commit

Permalink
handle SLASH_SLASH at beginning of network path
Browse files Browse the repository at this point in the history
  • Loading branch information
whyboris committed Aug 3, 2020
1 parent 06c74ca commit 6fb0d1f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const {
REPLACER_RE,

SLASH,
SLASH_SLASH,
BRACE_START,
BANG,
ONE_DOT,
Expand Down Expand Up @@ -96,11 +97,20 @@ const unifyPaths = (paths_) => {
return paths.map(normalizePathToUnix);
};

// If SLASH_SLASH occurs at the beginning of path, it is not replaced
// because "//StoragePC/DrivePool/Movies" is a valid network path
const toUnix = (string) => {
let str = string.replace(BACK_SLASH_RE, SLASH);
let prepend = false;
if (str.startsWith(SLASH_SLASH)) {
prepend = true;
}
while (str.match(DOUBLE_SLASH_RE)) {
str = str.replace(DOUBLE_SLASH_RE, SLASH);
}
if (prepend) {
str = SLASH + str;
}
return str;
};

Expand Down
1 change: 1 addition & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ exports.DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
exports.REPLACER_RE = /^\.[/\\]/;

exports.SLASH = '/';
exports.SLASH_SLASH = '//';
exports.BRACE_START = '{';
exports.BANG = '!';
exports.ONE_DOT = '.';
Expand Down
1 change: 0 additions & 1 deletion lib/fsevents-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ async checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts
try {
const stats = await stat(path)
if (this.fsw.closed) return;
if (this.fsw.closed) return;
if (sameTypes(info, stats)) {
this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
} else {
Expand Down

0 comments on commit 6fb0d1f

Please sign in to comment.