2023-07-28 13:20:56 +00:00
|
|
|
export function validatePageName(name: string) {
|
2023-07-06 14:47:50 +00:00
|
|
|
// Page can not be empty and not end with a file extension (e.g. "bla.md")
|
2023-07-28 13:20:56 +00:00
|
|
|
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");
|
|
|
|
}
|
2023-07-06 14:47:50 +00:00
|
|
|
}
|