Skip to content

Commit b31ac1c

Browse files
authored
Move case sensitivity check earlier in isDescendant (#8197)
1 parent f9104f4 commit b31ac1c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/common/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ function isWindowsPath(path: string): boolean {
103103
}
104104

105105
export function isDescendant(parent: string, descendant: string, separator: string = sep): boolean {
106+
// Windows is case insensitive
107+
if (isWindowsPath(parent)) {
108+
parent = parent.toLowerCase();
109+
descendant = descendant.toLowerCase();
110+
}
111+
106112
if (parent === descendant) {
107113
return true;
108114
}
@@ -111,12 +117,6 @@ export function isDescendant(parent: string, descendant: string, separator: stri
111117
parent += separator;
112118
}
113119

114-
// Windows is case insensitive
115-
if (isWindowsPath(parent)) {
116-
parent = parent.toLowerCase();
117-
descendant = descendant.toLowerCase();
118-
}
119-
120120
return descendant.startsWith(parent);
121121
}
122122

0 commit comments

Comments
 (0)