mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: format
This commit is contained in:
@@ -1,19 +1,25 @@
|
||||
export function sanitizeModuleName(moduleName: string, removeExtension: boolean = true): string {
|
||||
moduleName = moduleName.trim();
|
||||
export function sanitizeModuleName(
|
||||
moduleName: string,
|
||||
removeExtension: boolean = true
|
||||
): string {
|
||||
moduleName = moduleName.trim();
|
||||
|
||||
if (moduleName.startsWith("~/")) {
|
||||
moduleName = moduleName.substring(2);
|
||||
} else if (moduleName.startsWith("~")) {
|
||||
moduleName = moduleName.substring(1);
|
||||
} else if (moduleName.startsWith("/")) {
|
||||
moduleName = moduleName.substring(1);
|
||||
}
|
||||
if (moduleName.startsWith("~/")) {
|
||||
moduleName = moduleName.substring(2);
|
||||
} else if (moduleName.startsWith("~")) {
|
||||
moduleName = moduleName.substring(1);
|
||||
} else if (moduleName.startsWith("/")) {
|
||||
moduleName = moduleName.substring(1);
|
||||
}
|
||||
|
||||
if (removeExtension) {
|
||||
const extToRemove = ["js", "ts", "xml", "html", "css", "scss"];
|
||||
const extensionRegEx = new RegExp(`(.*)\\.(?:${extToRemove.join("|")})`, "i");
|
||||
moduleName = moduleName.replace(extensionRegEx, "$1");
|
||||
}
|
||||
if (removeExtension) {
|
||||
const extToRemove = ["js", "ts", "xml", "html", "css", "scss"];
|
||||
const extensionRegEx = new RegExp(
|
||||
`(.*)\\.(?:${extToRemove.join("|")})`,
|
||||
"i"
|
||||
);
|
||||
moduleName = moduleName.replace(extensionRegEx, "$1");
|
||||
}
|
||||
|
||||
return moduleName;
|
||||
return moduleName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user