Skip to content

Commit e6e6a8b

Browse files
author
Andy Hanson
committed
Use regex
1 parent c90897c commit e6e6a8b

1 file changed

Lines changed: 1 addition & 17 deletions

File tree

src/compiler/utilities.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,23 +1218,7 @@ namespace ts {
12181218
export function isExternalModuleNameRelative(moduleName: string): boolean {
12191219
// TypeScript 1.0 spec (April 2014): 11.2.1
12201220
// An external module name is "relative" if the first term is "." or "..".
1221-
if (moduleName.charCodeAt(0) === CharacterCodes.dot) {
1222-
if (moduleName.length === 1) {
1223-
return true;
1224-
}
1225-
switch (moduleName.charCodeAt(1)) {
1226-
case CharacterCodes.slash:
1227-
case CharacterCodes.backslash:
1228-
return true;
1229-
case CharacterCodes.dot:
1230-
if (moduleName.length === 2) {
1231-
return true;
1232-
}
1233-
const ch2 = moduleName.charCodeAt(2);
1234-
return ch2 === CharacterCodes.slash || ch2 === CharacterCodes.backslash;
1235-
}
1236-
}
1237-
return false;
1221+
return /^\.\.?($|[\\/])/.test(moduleName);
12381222
}
12391223

12401224
export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) {

0 commit comments

Comments
 (0)