mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 11:02:28 +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) {
|
||||
let fixedName: string;
|
||||
|
||||
if (origName === '') {
|
||||
fixedName = "unnamed";
|
||||
}
|
||||
else {
|
||||
const fixedName = (origName === '')
|
||||
? "unnamed"
|
||||
: origName.replace(/[^\p{L}\p{N}_:]/ug, "_");
|
||||
// any not allowed character should be replaced with underscore
|
||||
fixedName = origName.replace(/[^\p{L}\p{N}_:]/ug, "_");
|
||||
}
|
||||
|
||||
return fixedName;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user