mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-01 20:52:27 +08:00
refactor(sanitizeAttributeNames): use a ternary operator
This commit is contained in:
parent
afb91f82e1
commit
1053da3e40
@ -1,13 +1,8 @@
|
|||||||
export default function sanitizeAttributeName(origName: string) {
|
export default function sanitizeAttributeName(origName: string) {
|
||||||
let fixedName: string;
|
const fixedName = (origName === '')
|
||||||
|
? "unnamed"
|
||||||
if (origName === '') {
|
: origName.replace(/[^\p{L}\p{N}_:]/ug, "_");
|
||||||
fixedName = "unnamed";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// any not allowed character should be replaced with underscore
|
// any not allowed character should be replaced with underscore
|
||||||
fixedName = origName.replace(/[^\p{L}\p{N}_:]/ug, "_");
|
|
||||||
}
|
|
||||||
|
|
||||||
return fixedName;
|
return fixedName;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user