mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
feat: burg group editor - form
This commit is contained in:
parent
32808605b3
commit
d8009f84ad
8 changed files with 156 additions and 53 deletions
|
|
@ -56,3 +56,18 @@ JSON.isValid = str => {
|
|||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
function sanitizeId(string) {
|
||||
if (!string) throw new Error("No string provided");
|
||||
|
||||
let sanitized = string
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/[^a-z0-9-_]/g, "") // no invalid characters
|
||||
.replace(/\s+/g, "-"); // replace spaces with hyphens
|
||||
|
||||
// remove leading numbers
|
||||
if (sanitized.match(/^\d/)) sanitized = "_" + sanitized;
|
||||
|
||||
return sanitized;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue