fix: dots can now be used in module names (#7655)

Only known extensions are stripped from the end of module names
This commit is contained in:
Nicu
2019-08-21 00:01:53 +03:00
committed by Svetoslav
parent b0d1c9106a
commit b6ff4d376a
3 changed files with 18 additions and 6 deletions

View File

@ -10,11 +10,10 @@ export function sanitizeModuleName(moduleName: string, removeExtension: boolean
}
if (removeExtension) {
const lastDot = moduleName.lastIndexOf(".");
if (lastDot > 0) {
moduleName = moduleName.substr(0, lastDot);
}
const extToRemove = ["js", "ts", "xml", "html", "css", "scss"];
const extensionRegEx = new RegExp(`(.*)\\.(?:${extToRemove.join("|")})`, "i");
moduleName = moduleName.replace(extensionRegEx, "$1");
}
return moduleName;
}
}