feat: test item, when icon is svg, add svg format check

This commit is contained in:
huzibaca 2024-10-01 20:49:03 +08:00
parent 0b8f24a92e
commit 0e1e54aff4
No known key found for this signature in database
GPG Key ID: D4364EE4851DC302

View File

@ -67,6 +67,16 @@ export const TestViewer = forwardRef<TestViewerRef, Props>((props, ref) => {
let newList;
let uid;
if (form.icon && form.icon.startsWith("<svg")) {
const doc = new DOMParser().parseFromString(
form.icon,
"image/svg+xml"
);
if (doc.querySelector("parsererror")) {
throw new Error("`Icon`svg format error");
}
}
if (openType === "new") {
uid = nanoid();
const item = { ...form, uid };