mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
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:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user