From e6e6a8b1102d1ee5aca429350d5c22e6c0ddd1c9 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 13 Jul 2016 09:55:57 -0700 Subject: [PATCH] Use regex --- src/compiler/utilities.ts | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 8dbc052ddc..4a8391338c 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1218,23 +1218,7 @@ namespace ts { export function isExternalModuleNameRelative(moduleName: string): boolean { // TypeScript 1.0 spec (April 2014): 11.2.1 // An external module name is "relative" if the first term is "." or "..". - if (moduleName.charCodeAt(0) === CharacterCodes.dot) { - if (moduleName.length === 1) { - return true; - } - switch (moduleName.charCodeAt(1)) { - case CharacterCodes.slash: - case CharacterCodes.backslash: - return true; - case CharacterCodes.dot: - if (moduleName.length === 2) { - return true; - } - const ch2 = moduleName.charCodeAt(2); - return ch2 === CharacterCodes.slash || ch2 === CharacterCodes.backslash; - } - } - return false; + return /^\.\.?($|[\\/])/.test(moduleName); } export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) {