diff --git a/js/router.js b/js/router.js
index 402d20e..588df1c 100644
--- a/js/router.js
+++ b/js/router.js
@@ -48,7 +48,8 @@ export function initRouter(root) {
renderPageTransition(root, ` Double-check the URL or explore the tools hub.Tool not found.
\n
${escapeHtml(line)}
`); + const paragraph = escapeHtml(line); + html.push(`${paragraph}
`); } }); flushList(); diff --git a/js/tools/schema.js b/js/tools/schema.js index 44255b3..e721869 100644 --- a/js/tools/schema.js +++ b/js/tools/schema.js @@ -76,14 +76,18 @@ async function init() { function validateData(schema, data, path) { const errors = []; if (schema.type) { + const typeError = (expected) => `${path} should be ${expected}`; if (schema.type === 'object') { if (typeof data !== 'object' || data === null || Array.isArray(data)) { - errors.push(`${path} should be an object`); + errors.push(typeError('an object')); return errors; } if (schema.required) { schema.required.forEach((key) => { - if (!(key in data)) errors.push(`${path} missing required property ${key}`); + if (!(key in data)) { + const missingPropertyMessage = `${path} missing required property ${key}`; + errors.push(missingPropertyMessage); + } }); } if (schema.properties) { @@ -95,18 +99,18 @@ function validateData(schema, data, path) { } } else if (schema.type === 'array') { if (!Array.isArray(data)) { - errors.push(`${path} should be an array`); + errors.push(typeError('an array')); } else if (schema.items) { data.forEach((item, index) => { errors.push(...validateData(schema.items, item, `${path}/${index}`)); }); } } else if (schema.type === 'string') { - if (typeof data !== 'string') errors.push(`${path} should be a string`); + if (typeof data !== 'string') errors.push(typeError('a string')); } else if (schema.type === 'number') { - if (typeof data !== 'number') errors.push(`${path} should be a number`); + if (typeof data !== 'number') errors.push(typeError('a number')); } else if (schema.type === 'boolean') { - if (typeof data !== 'boolean') errors.push(`${path} should be a boolean`); + if (typeof data !== 'boolean') errors.push(typeError('a boolean')); } } return errors; diff --git a/js/tools/sqlfmt.js b/js/tools/sqlfmt.js index 9a6f82f..6e7da97 100644 --- a/js/tools/sqlfmt.js +++ b/js/tools/sqlfmt.js @@ -66,7 +66,8 @@ function formatSql(sql) { } else if (token === 'BY') { current.push(token); } else if (token === 'AND' || token === 'OR') { - current.push(`\n ${token}`); + const clauseToken = `\n ${token}`; + current.push(clauseToken); } else { current.push(token); } diff --git a/js/utils/dates.js b/js/utils/dates.js index df739e2..850f22f 100644 --- a/js/utils/dates.js +++ b/js/utils/dates.js @@ -86,7 +86,8 @@ export function convertToZone(date, zone = 'UTC') { second: '2-digit' }).format(safeDate); } catch (error) { - throw new Error(`Unsupported time zone: ${zone}`); + const message = `Unsupported time zone: ${zone}`; + throw new Error(message); } }