Fix css name sanitization

This commit is contained in:
Zoe Roux
2023-01-07 13:52:47 +09:00
parent 70c9d8d9d5
commit 428f13365e
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "yoshiki",
"version": "0.3.4",
"version": "0.3.5",
"author": "Zoe Roux <zoe.roux@sdg.moe> (https://github.com/AnonymusRaccoon)",
"license": "MIT",
"keywords": [
+2 -1
View File
@@ -43,7 +43,8 @@ const stateMapper: {
const sanitize = (className: unknown) => {
const name = typeof className === "string" ? className : JSON.stringify(className);
if (name === undefined) return "undefined";
return name.replaceAll(/[^\w\d_]/g, "");
// Keep - as a _ for minus symbols.
return name.replaceAll("-", "_").replaceAll(/[^\w\d_]/g, "");
};
type PreprocessBlockFunction = (block: { [key: string]: unknown }) => { [key: string]: unknown };