🐛 Fix IAL name checking functionality (#8204)

This commit is contained in:
颖逸 2023-05-08 14:45:45 +08:00 committed by GitHub
parent 9950848a4e
commit 0d5b04e4dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -42,6 +42,10 @@ export const isFileAnnotation = (text: string) => {
return /^<<assets\/.+\/\d{14}-\w{7} ".+">>$/.test(text);
};
export const isValidAttrName = (name: string) => {
return /^[_a-zA-Z][_.\-0-9a-zA-Z]*$/.test(name);
};
// REF https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/eval
export const looseJsonParse = (text: string) => {
return Function(`"use strict";return (${text})`)();