diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/sanitize_JSON.js | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/common/sanitize_JSON.js b/common/sanitize_JSON.js index 3fc5007..8268d3e 100644 --- a/common/sanitize_JSON.js +++ b/common/sanitize_JSON.js @@ -31,7 +31,6 @@ function error_message(cause) function sanitize_unknown(schema, item) { - console.log(`sanitize_unknown ${JSON.stringify(schema)}`); let error_msg = undefined; let schema_options = []; let has_default = false; @@ -89,9 +88,7 @@ function sanitize_unknown(schema, item) function sanitize_unknown_no_alternatives(schema, item) { - console.log(`sanitize_unknown_no_alternatives ${JSON.stringify(schema)}`); for (const [schema_check, item_check, sanitizer, type_name] of checks) { - console.log(`checking ${type_name}`); if (schema_check(schema)) { if (item_check(item)) return sanitizer(schema, item); @@ -205,7 +202,6 @@ function sanitize_genobj(schema, object) function sanitize_array(schema, array) { - console.log(`sanitize_array ${JSON.stringify(schema)}`); let min_length = 0; let max_length = Infinity; let repeat_length = 1; @@ -231,14 +227,14 @@ function sanitize_array(schema, array) } if (["repeat", "repeatfull"].includes(schema[schema.length - 1])) { var repeat_directive = schema.pop(); - repeat = schema.splice(schema.length - repeat_length); + var repeat = schema.splice(schema.length - repeat_length); } else if (schema.length !== array.length) { - throw error_message(`does not not have exactly ${schema.length} items`); + throw error_message(`does not have exactly ${schema.length} items`); } if (repeat_directive === "repeatfull" && (array.length - schema.length) % repeat_length !== 0) - throw error_message(`does not not contain a full number of item group repetitions`); + throw error_message(`does not contain a full number of item group repetitions`); if (array.length < min_length) throw error_message(`has less than ${min_length} element${min_length === 1 ? "" : "s"}`); @@ -246,8 +242,6 @@ function sanitize_array(schema, array) if (array.length > max_length) throw error_message(`has more than ${max_length} element${max_length === 1 ? "" : "s"}`); - console.log(schema, repeat); - for (const item of array) { if (i >= schema.length) { i = 0; @@ -268,7 +262,6 @@ function sanitize_array(schema, array) function sanitize_regex(schema, string) { - console.log(`sanitize_regex ${schema}`); if (schema.test(string)) return string; @@ -279,7 +272,6 @@ const string_spec_regex = /^string(:(.*))?$/; function sanitize_string(schema, string) { - console.log(`sanitize_string ${JSON.stringify(schema)}`); const regex = string_spec_regex.exec(schema)[2]; if (regex === undefined) @@ -290,7 +282,6 @@ function sanitize_string(schema, string) function sanitize_object(schema, object) { - console.log(`sanitize_object ${JSON.stringify(schema)}`); const result = {}; for (let [key, entry_schema] of Object.entries(schema)) { @@ -304,7 +295,6 @@ function sanitize_object(schema, object) function sanitize_object_entry(result, key, entry_schema, object) { - console.log(`sanitize_object_entry ${JSON.stringify(entry_schema)}`); let optional = false; let has_default = false; let _default = undefined; @@ -347,7 +337,6 @@ function sanitize_object_entry(result, key, entry_schema, object) function take_literal(schema, item) { - console.log(`take_literal ${JSON.stringify(schema)}`); return item; } @@ -357,7 +346,6 @@ function take_literal(schema, item) */ function discard(schema, item) { - console.log(`discard ${JSON.stringify(schema)}`); return discard; } |