mirror of https://github.com/status-im/metro.git
Protect against roots that are contained within other roots
Summary: For example, I could have a root named `random` and another root named `randomColor`. A child of `randomColor` would **incorrectly** pass as a descendant of `random`. So this commit changes `isDescendant` to do 2 things: - check for exact matches (eg: the path is a root) - call `startsWith` like before, but append `path.sep` to avoid false positives Closes https://github.com/facebook/react-native/pull/9831 Differential Revision: D3864968 fbshipit-source-id: 7fe04913579aa0741840fc925216283304ae3433
This commit is contained in:
parent
0e06c0f74f
commit
bc0c34967e
|
@ -70,7 +70,7 @@ function watchmanRecReadDir(roots, {ignore, fileWatcher, exts}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDescendant(root, child) {
|
function isDescendant(root, child) {
|
||||||
return child.startsWith(root);
|
return root === child || child.startsWith(root + path.sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = watchmanRecReadDir;
|
module.exports = watchmanRecReadDir;
|
||||||
|
|
|
@ -362,7 +362,7 @@ function makeReadCallback(fd, predicate, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDescendant(root, child) {
|
function isDescendant(root, child) {
|
||||||
return child.startsWith(root);
|
return root === child || child.startsWith(root + path.sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Fastfs;
|
module.exports = Fastfs;
|
||||||
|
|
Loading…
Reference in New Issue