From bc0ac2467e7cf04cbca78bf3dd3abf0e21d4aca4 Mon Sep 17 00:00:00 2001 From: D Zuloaga Date: Wed, 8 Jun 2022 19:40:11 -0400 Subject: [PATCH] play nice with html-loader --- src/parseQuery.ts | 1 + test/sharp/build/__snapshots__/test.js.snap | 22 --------------------- test/sharp/index.js | 7 +------ 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/parseQuery.ts b/src/parseQuery.ts index 0c39658..7672f87 100644 --- a/src/parseQuery.ts +++ b/src/parseQuery.ts @@ -22,6 +22,7 @@ function parseQuery(query: string): LooseObject { } if (query.slice(0, 1) === '{' && query.slice(-1) === '}') { + query = decodeURIComponent(query) return JSON5.parse(query) } diff --git a/test/sharp/build/__snapshots__/test.js.snap b/test/sharp/build/__snapshots__/test.js.snap index 8502758..c0711f3 100644 --- a/test/sharp/build/__snapshots__/test.js.snap +++ b/test/sharp/build/__snapshots__/test.js.snap @@ -252,28 +252,6 @@ Object { } `; -exports[`parses json notation with singleQuotes 1`] = ` -Object { - "height": 91, - "images": Array [ - Object { - "height": 47, - "path": "foobar/064e7e9c9d1af8543b88b2331becb082-52.webp", - "width": 52, - }, - Object { - "height": 91, - "path": "foobar/8f3bb7e057d40b23a28b1eeed1232feb-102.webp", - "width": 102, - }, - ], - "src": "foobar/8f3bb7e057d40b23a28b1eeed1232feb-102.webp", - "srcSet": "foobar/064e7e9c9d1af8543b88b2331becb082-52.webp 52w,foobar/8f3bb7e057d40b23a28b1eeed1232feb-102.webp 102w", - "toString": [Function], - "width": 102, -} -`; - exports[`png 1`] = ` Object { "height": 595, diff --git a/test/sharp/index.js b/test/sharp/index.js index bd22033..b8b9430 100644 --- a/test/sharp/index.js +++ b/test/sharp/index.js @@ -40,12 +40,7 @@ test('multiple sizes', () => { }) test('parses json notation', () => { - const multi = require("../cat-1000.jpg?{sizes:[50,100,200], format: 'webp'}") - expect(multi).toMatchSnapshot() -}) - -test('parses json notation with singleQuotes', () => { - const multi = require('../cat-1000.jpg?{sizes:[52,102], format: "webp"}') + const multi = require('../cat-1000.jpg?{sizes:[50,100,200], format: "webp"}') expect(multi).toMatchSnapshot() })