Skip to content

Commit

Permalink
patch to protect schema importing
Browse files Browse the repository at this point in the history
  • Loading branch information
DecDuck committed Aug 18, 2024
1 parent fa28c9e commit b16cf9d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pages/projects/[projectid]/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,25 @@ const schemaValidation = computed(() =>
const importSchemaUrl = ref();
function importSchema() {
async function importSchema() {
if (!importSchemaUrl.value) {
importSchemaUrl.value = "";
return;
}
if (project.value.schemas.includes(importSchemaUrl.value)) {
importSchemaUrl.value = "";
return;
}
const schema = await $fetch(importSchemaUrl.value);
if (typeof schema !== "object") {
importSchemaUrl.value = "";
return;
}
const schemaResults = validateSchema(schema);
if (schemaResults[1] == 0) {
importSchemaUrl.value = "";
return;
}
project.value.schemas.push(importSchemaUrl.value);
importSchemaUrl.value = "";
}
Expand Down

0 comments on commit b16cf9d

Please sign in to comment.