Fixes #453: batch prefix refactor command

This commit is contained in:
Zef Hemel
2023-07-28 15:20:56 +02:00
parent 747e81e5da
commit 891c8fb995
7 changed files with 345 additions and 255 deletions
+10 -2
View File
@@ -1,4 +1,12 @@
export function isValidPageName(name: string): boolean {
export function validatePageName(name: string) {
// Page can not be empty and not end with a file extension (e.g. "bla.md")
return name !== "" && !name.startsWith(".") && !/\.[a-zA-Z]+$/.test(name);
if (name === "") {
throw new Error("Page name can not be empty");
}
if (name.startsWith(".")) {
throw new Error("Page name cannot start with a '.'");
}
if (/\.[a-zA-Z]+$/.test(name)) {
throw new Error("Page name can not end with a file extension");
}
}