From 4e43dcdc05074d9f28efa2232e328f2bc0002d85 Mon Sep 17 00:00:00 2001 From: Jordi Oliveras Rovira Date: Sun, 9 Dec 2018 20:22:06 +0100 Subject: [PATCH] Change usages of String.prototype.endsWith to ts.endsWith. --- src/services/rename.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/services/rename.ts b/src/services/rename.ts index 7ba32c91309..1175ce847fe 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -45,8 +45,7 @@ namespace ts.Rename { const moduleSourceFile = find(moduleSymbol.declarations, isSourceFile); if (!moduleSourceFile) return undefined; - const withoutIndex = node.text.endsWith("/index") || node.text.endsWith("/index.js") ? undefined : tryRemoveSuffix(removeFileExtension(moduleSourceFile.fileName), "/index"); - const name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; + const withoutIndex = endsWith(node.text, "/index") || endsWith(node.text, "/index.js") ? undefined : tryRemoveSuffix(removeFileExtension(moduleSourceFile.fileName), "/index"); const name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; const kind = withoutIndex === undefined ? ScriptElementKind.moduleElement : ScriptElementKind.directory; const indexAfterLastSlash = node.text.lastIndexOf("/") + 1; // Span should only be the last component of the path. + 1 to account for the quote character.