1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 00:35:26 +03:00

Disable Schema validation for ChromeOS (#1802)

Disable Schema validation for ChromeOS
This commit is contained in:
Michael Keller 2019-11-06 13:32:34 +13:00 committed by GitHub
commit 37f26d5032
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,20 +111,26 @@ TABS.vtx.initialize = function (callback) {
// Load schema // Load schema
const urlVtxSchema = chrome.runtime.getURL(`resources/jsonschema/vtxconfig_schema-${vtxConfig.version}.json`); const urlVtxSchema = chrome.runtime.getURL(`resources/jsonschema/vtxconfig_schema-${vtxConfig.version}.json`);
fetch(urlVtxSchema) if (GUI.Mode === GUI_Modes.ChromeApp) {
.then(response => response.json()) // FIXME the ChromeOs don't let us use a Schema Validator because almost all of them use eval, and/or use require
.catch(error => console.error('Error fetching VTX Schema:', error)) callback_valid();
.then(schemaJson => { } else {
fetch(urlVtxSchema)
.then(response => response.json())
.catch(error => console.error('Error fetching VTX Schema:', error))
.then(schemaJson => {
let valid = false; let valid = false;
if (schemaJson !== undefined) { if (schemaJson !== undefined) {
// Validate // Validate
valid = (TABS.vtx.env.validate(schemaJson, vtxConfig) === undefined); valid = (TABS.vtx.env.validate(schemaJson, vtxConfig) === undefined);
}
console.log("Validation against schema result:", valid);
valid ? callback_valid() : callback_error();
} }
);
console.log("Validation against schema result:", valid); }
valid ? callback_valid() : callback_error();
});
} }