aboutsummaryrefslogtreecommitdiff
path: root/dev/manifest-util.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-19 00:33:38 -0500
committerGitHub <noreply@github.com>2023-12-19 05:33:38 +0000
commit1ced9aafc00c10992bab8bd3f1b6b1397f05b7b9 (patch)
tree305bb2b3bfc7fc3b051ee1cd3d1c35f442af0de4 /dev/manifest-util.js
parent5f96276fda93dcad39f2165fd3c8d890aa5f9be5 (diff)
Make JSON.parse usage safer (#373)
* Make JSON.parse usage safer * Fix any type * Add readResponseJson * Use readResponseJson * Additional updates * Rename files * Add types
Diffstat (limited to 'dev/manifest-util.js')
-rw-r--r--dev/manifest-util.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/dev/manifest-util.js b/dev/manifest-util.js
index 638706d8..ac9b58db 100644
--- a/dev/manifest-util.js
+++ b/dev/manifest-util.js
@@ -20,6 +20,7 @@ import childProcess from 'child_process';
import fs from 'fs';
import {fileURLToPath} from 'node:url';
import path from 'path';
+import {parseJson} from './json.js';
const dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -29,14 +30,14 @@ const dirname = path.dirname(fileURLToPath(import.meta.url));
* @returns {T}
*/
function clone(value) {
- return JSON.parse(JSON.stringify(value));
+ return parseJson(JSON.stringify(value));
}
export class ManifestUtil {
constructor() {
const fileName = path.join(dirname, 'data', 'manifest-variants.json');
- const {manifest, variants, defaultVariant} = /** @type {import('dev/manifest').ManifestConfig} */ (JSON.parse(fs.readFileSync(fileName, {encoding: 'utf8'})));
+ const {manifest, variants, defaultVariant} = /** @type {import('dev/manifest').ManifestConfig} */ (parseJson(fs.readFileSync(fileName, {encoding: 'utf8'})));
/** @type {import('dev/manifest').Manifest} */
this._manifest = manifest;
/** @type {import('dev/manifest').ManifestVariant[]} */