From d16739a83a20e1729e08dbcbbc155be15972d146 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 22 May 2021 15:45:20 -0400 Subject: Json schema validation improvements (#1697) * Create new JsonSchema class * Add proxy handler * Update tests * Update validation scripts * Update backend * Update audio downloader * Update options util * Update dictionary importer * Update json schema file reference * Remove old json-schema.js * Rename new json-schema.js * Update file names * Rename class --- ext/js/media/audio-downloader.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ext/js/media') diff --git a/ext/js/media/audio-downloader.js b/ext/js/media/audio-downloader.js index 47cdaf13..577d1c1b 100644 --- a/ext/js/media/audio-downloader.js +++ b/ext/js/media/audio-downloader.js @@ -16,7 +16,7 @@ */ /* global - * JsonSchemaValidator + * JsonSchema * NativeSimpleDOMParser * SimpleDOMParser */ @@ -26,7 +26,7 @@ class AudioDownloader { this._japaneseUtil = japaneseUtil; this._requestBuilder = requestBuilder; this._customAudioListSchema = null; - this._schemaValidator = null; + this._customAudioListSchema = null; this._getInfoHandlers = new Map([ ['jpod101', this._getInfoJpod101.bind(this)], ['jpod101-alternate', this._getInfoJpod101Alternate.bind(this)], @@ -222,11 +222,11 @@ class AudioDownloader { const responseJson = await response.json(); - const schema = await this._getCustomAudioListSchema(); - if (this._schemaValidator === null) { - this._schemaValidator = new JsonSchemaValidator(); + if (this._customAudioListSchema === null) { + const schema = await this._getCustomAudioListSchema(); + this._customAudioListSchema = new JsonSchema(schema); } - this._schemaValidator.validate(responseJson, schema); + this._customAudioListSchema.validate(responseJson); const results = []; for (const {url: url2, name} of responseJson.audioSources) { -- cgit v1.2.3