mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-16 06:42:53 +00:00
11 lines
295 B
TypeScript
11 lines
295 B
TypeScript
export const isValidIdentifier = (name: string) => {
|
|
return /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(name);
|
|
};
|
|
|
|
export const ensureValidClassName = (name: string) => {
|
|
if (!isValidIdentifier(name)) {
|
|
return `$${name.replace(/[^_$a-zA-Z0-9]/g, '')}`;
|
|
}
|
|
return name;
|
|
};
|