diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2023-12-19 00:33:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-19 05:33:38 +0000 |
commit | 1ced9aafc00c10992bab8bd3f1b6b1397f05b7b9 (patch) | |
tree | 305bb2b3bfc7fc3b051ee1cd3d1c35f442af0de4 /ext/js/dom | |
parent | 5f96276fda93dcad39f2165fd3c8d890aa5f9be5 (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 'ext/js/dom')
-rw-r--r-- | ext/js/dom/sandbox/css-style-applier.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/js/dom/sandbox/css-style-applier.js b/ext/js/dom/sandbox/css-style-applier.js index 200fd05f..6925f263 100644 --- a/ext/js/dom/sandbox/css-style-applier.js +++ b/ext/js/dom/sandbox/css-style-applier.js @@ -16,6 +16,8 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +import {readResponseJson} from '../../core/json.js'; + /** * This class is used to apply CSS styles to elements using a consistent method * that is the same across different browsers. @@ -99,8 +101,9 @@ export class CssStyleApplier { /** * Fetches and parses a JSON file. + * @template [T=unknown] * @param {string} url The URL to the file. - * @returns {Promise<*>} A JSON object. + * @returns {Promise<T>} A JSON object. * @throws {Error} An error is thrown if the fetch fails. */ async _fetchJsonAsset(url) { @@ -115,7 +118,7 @@ export class CssStyleApplier { if (!response.ok) { throw new Error(`Failed to fetch ${url}: ${response.status}`); } - return await response.json(); + return await readResponseJson(response); } /** |