Skip to content

Commit 61f9a69

Browse files
authoredJul 25, 2024··
feat: reduce runtime code
1 parent a2463ca commit 61f9a69

12 files changed

+3540
-4606
lines changed
 

‎src/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ export default async function loader(content) {
8080
html = await options.postprocessor(html, this);
8181
}
8282

83-
const importCode = getImportCode(html, this, imports, options);
84-
const moduleCode = getModuleCode(html, replacements, {
83+
const importCode = getImportCode(html, imports, options);
84+
const moduleCode = getModuleCode(html, replacements, this, {
85+
esModule: options.esModule,
8586
isTemplateLiteralSupported,
8687
});
8788
const exportCode = getExportCode(html, options);

‎src/plugins/sources-plugin.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,7 @@ export default (options) =>
139139
let offset = 0;
140140

141141
for (const source of sources) {
142-
const {
143-
name,
144-
value,
145-
isValueQuoted,
146-
format,
147-
runtime,
148-
startOffset,
149-
endOffset,
150-
} = source;
142+
const { name, value, isValueQuoted, startOffset, endOffset } = source;
151143

152144
let request = value;
153145

@@ -172,7 +164,7 @@ export default (options) =>
172164
importName = `___HTML_LOADER_IMPORT_${imports.size}___`;
173165
imports.set(request, importName);
174166

175-
options.imports.push({ format, importName, request });
167+
options.imports.push({ importName, request });
176168
}
177169

178170
const replacementKey = JSON.stringify({ request, isValueQuoted, hash });
@@ -187,7 +179,6 @@ export default (options) =>
187179
importName,
188180
hash,
189181
isValueQuoted,
190-
runtime,
191182
});
192183
}
193184

‎src/runtime/getUrl.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
module.exports = (url, options) => {
2-
if (!options) {
3-
// eslint-disable-next-line no-param-reassign
4-
options = {};
5-
}
6-
1+
module.exports = (url, maybeNeedQuotes) => {
72
if (!url) {
83
return url;
94
}
105

116
// eslint-disable-next-line no-underscore-dangle, no-param-reassign
12-
url = String(url.__esModule ? url.default : url);
13-
14-
if (options.hash) {
15-
// eslint-disable-next-line no-param-reassign
16-
url += options.hash;
17-
}
7+
url = String(url);
188

19-
if (options.maybeNeedQuotes && /[\t\n\f\r "'=<>`]/.test(url)) {
9+
if (maybeNeedQuotes && /[\t\n\f\r "'=<>`]/.test(url)) {
2010
return `"${url}"`;
2111
}
2212

‎src/utils.js

+42-53
Original file line numberDiff line numberDiff line change
@@ -1218,43 +1218,21 @@ export function getFilter(filter) {
12181218
};
12191219
}
12201220

1221-
const GET_SOURCE_FROM_IMPORT_NAME = "___HTML_LOADER_GET_SOURCE_FROM_IMPORT___";
1222-
1223-
export function getImportCode(html, loaderContext, imports, options) {
1221+
export function getImportCode(html, imports, options) {
12241222
if (imports.length === 0) {
12251223
return "";
12261224
}
12271225

1228-
// TODO simplify in the next major release
1229-
const getURLRuntime = require.resolve("./runtime/getUrl.js");
1230-
const context = loaderContext.context || loaderContext.rootContext;
1231-
const fileURLToHelper =
1232-
typeof loaderContext.utils !== "undefined" &&
1233-
typeof loaderContext.utils.contextify === "function"
1234-
? loaderContext.utils.contextify(context, getURLRuntime)
1235-
: contextify(context, getURLRuntime);
1236-
1237-
let code = options.esModule
1238-
? `import ${GET_SOURCE_FROM_IMPORT_NAME} from "${fileURLToHelper}";\n`
1239-
: `var ${GET_SOURCE_FROM_IMPORT_NAME} = require("${fileURLToHelper}");\n`;
1226+
let code = "";
12401227

12411228
for (const item of imports) {
1242-
const { format, importName, request } = item;
1229+
const { importName, request } = item;
12431230

1244-
switch (format) {
1245-
case "import":
1246-
code += options.esModule
1247-
? `import ${importName} from ${JSON.stringify(request)};\n`
1248-
: `var ${importName} = require(${JSON.stringify(request)});\n`;
1249-
break;
1250-
case "url":
1251-
default:
1252-
code += options.esModule
1253-
? `var ${importName} = new URL(${JSON.stringify(
1254-
request,
1255-
)}, import.meta.url);\n`
1256-
: `var ${importName} = require(${JSON.stringify(request)});\n`;
1257-
}
1231+
code += options.esModule
1232+
? `var ${importName} = new URL(${JSON.stringify(
1233+
request,
1234+
)}, import.meta.url);\n`
1235+
: `var ${importName} = require(${JSON.stringify(request)});\n`;
12581236
}
12591237

12601238
return `// Imports\n${code}`;
@@ -1279,44 +1257,55 @@ export function convertToTemplateLiteral(str) {
12791257
return `\`${escapedString}\``;
12801258
}
12811259

1282-
export function getModuleCode(html, replacements, options) {
1260+
const GET_SOURCE_FROM_IMPORT_NAME = "___HTML_LOADER_GET_SOURCE_FROM_IMPORT___";
1261+
1262+
export function getModuleCode(html, replacements, loaderContext, options) {
12831263
let code = html;
1284-
let replacersCode = "";
12851264

12861265
const { isTemplateLiteralSupported } = options;
12871266

1267+
let needHelperImport = false;
1268+
12881269
for (const item of replacements) {
1289-
const { runtime, importName, replacementName, isValueQuoted, hash } = item;
1270+
const { importName, replacementName, isValueQuoted, hash } = item;
12901271

1291-
if (typeof runtime === "undefined" || runtime === true) {
1292-
const getUrlOptions = []
1293-
.concat(hash ? [`hash: ${JSON.stringify(hash)}`] : [])
1294-
.concat(isValueQuoted ? [] : "maybeNeedQuotes: true");
1295-
const preparedOptions =
1296-
getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(", ")} }` : "";
1272+
if (!isValueQuoted && !needHelperImport) {
1273+
needHelperImport = true;
1274+
}
12971275

1298-
replacersCode += `var ${replacementName} = ${GET_SOURCE_FROM_IMPORT_NAME}(${importName}${preparedOptions});\n`;
1276+
const name = !isValueQuoted
1277+
? `${GET_SOURCE_FROM_IMPORT_NAME}(${importName}${!isValueQuoted ? ", true" : ""})`
1278+
: importName;
12991279

1300-
code = code.replace(new RegExp(replacementName, "g"), () =>
1301-
isTemplateLiteralSupported
1302-
? `\${${replacementName}}`
1303-
: `" + ${replacementName} + "`,
1304-
);
1305-
} else {
1306-
code = code.replace(new RegExp(replacementName, "g"), () =>
1307-
isTemplateLiteralSupported
1308-
? `\${${replacementName}}`
1309-
: `" + ${replacementName} + "`,
1310-
);
1311-
}
1280+
code = code.replace(new RegExp(replacementName, "g"), () =>
1281+
isTemplateLiteralSupported
1282+
? `\${${name}}${typeof hash !== "undefined" ? hash : ""}`
1283+
: `" + ${name}${typeof hash !== "undefined" ? ` + ${JSON.stringify(hash)}` : ""} + "`,
1284+
);
13121285
}
13131286

13141287
// Replaces "<script>" or "</script>" to "<" + "script>" or "<" + "/script>".
13151288
code = code.replace(/<(\/?script)/g, (_, s) =>
13161289
isTemplateLiteralSupported ? `\${"<" + "${s}"}` : `<" + "${s}`,
13171290
);
13181291

1319-
return `// Module\n${replacersCode}var code = ${code};\n`;
1292+
code = `// Module\nvar code = ${code};\n`;
1293+
1294+
if (needHelperImport) {
1295+
// TODO simplify in the next major release
1296+
const getURLRuntime = require.resolve("./runtime/getUrl.js");
1297+
const context = loaderContext.context || loaderContext.rootContext;
1298+
const fileURLToHelper =
1299+
typeof loaderContext.utils !== "undefined" &&
1300+
typeof loaderContext.utils.contextify === "function"
1301+
? loaderContext.utils.contextify(context, getURLRuntime)
1302+
: contextify(context, getURLRuntime);
1303+
code = options.esModule
1304+
? `import ${GET_SOURCE_FROM_IMPORT_NAME} from "${fileURLToHelper}";\n${code}`
1305+
: `var ${GET_SOURCE_FROM_IMPORT_NAME} = require("${fileURLToHelper}");\n${code}`;
1306+
}
1307+
1308+
return code;
13201309
}
13211310

13221311
export function getExportCode(html, options) {

‎test/__snapshots__/esModule-option.test.js.snap

+506-615
Large diffs are not rendered by default.

‎test/__snapshots__/loader.test.js.snap

+353-439
Large diffs are not rendered by default.

‎test/__snapshots__/minimize-option.test.js.snap

+519-743
Large diffs are not rendered by default.

‎test/__snapshots__/postprocessor-option.test.js.snap

+3-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ exports[`'postprocess' option should work with async "postprocessor" function op
44

55
exports[`'postprocess' option should work with async "postprocessor" function option: module 1`] = `
66
"// Imports
7-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
87
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
98
// Module
10-
var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___);
119
var code = \`<div>
1210
<p>{{firstname}} {{lastname}}</p>
13-
<img src="\${___HTML_LOADER_REPLACEMENT_0___}" alt="alt" />
11+
<img src="\${___HTML_LOADER_IMPORT_0___}" alt="alt" />
1412
<div>
1513
\`;
1614
// Exports
@@ -31,11 +29,9 @@ exports[`'postprocess' option should work with the "postprocessor" option #1: er
3129
3230
exports[`'postprocess' option should work with the "postprocessor" option #1: module 1`] = `
3331
"// Imports
34-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
3532
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
3633
// Module
37-
var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___);
38-
var code = "<img src=\\"" + ___HTML_LOADER_REPLACEMENT_0___ + "\\">\\n<img src=\\"" + 'Hello ' + (1+1) + "\\">\\n<img src=\\"" + require('./image.png') + "\\">\\n<img src=\\"" + new URL('./image.png', import.meta.url) + "\\">\\n<div>" + require('./gallery.html').default + "</div>\\n<!--Works fine, but need improve testing <div>< %= (await import('./gallery.html')).default % ></div>-->\\n";
34+
var code = "<img src=\\"" + ___HTML_LOADER_IMPORT_0___ + "\\">\\n<img src=\\"" + 'Hello ' + (1+1) + "\\">\\n<img src=\\"" + require('./image.png') + "\\">\\n<img src=\\"" + new URL('./image.png', import.meta.url) + "\\">\\n<div>" + require('./gallery.html').default + "</div>\\n<!--Works fine, but need improve testing <div>< %= (await import('./gallery.html')).default % ></div>-->\\n";
3935
// Exports
4036
export default code;"
4137
`;
@@ -56,11 +52,9 @@ exports[`'postprocess' option should work with the "postprocessor" option: error
5652
5753
exports[`'postprocess' option should work with the "postprocessor" option: module 1`] = `
5854
"// Imports
59-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
6055
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
6156
// Module
62-
var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___);
63-
var code = \`<img src="\${___HTML_LOADER_REPLACEMENT_0___}">
57+
var code = \`<img src="\${___HTML_LOADER_IMPORT_0___}">
6458
<img src="\${ 'Hello ' + (1+1) }">
6559
<img src="\${ require('./image.png') }">
6660
<img src="\${ new URL('./image.png', import.meta.url) }">

‎test/__snapshots__/preprocessor-option.test.js.snap

+4-14
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ exports[`'preprocess' option should work with async "preprocessor" function opti
44

55
exports[`'preprocess' option should work with async "preprocessor" function option: module 1`] = `
66
"// Imports
7-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
87
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
98
// Module
10-
var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___);
119
var code = \`<div>
1210
<p>Alexander Krasnoyarov</p>
13-
<img src="\${___HTML_LOADER_REPLACEMENT_0___}" alt="alt" />
11+
<img src="\${___HTML_LOADER_IMPORT_0___}" alt="alt" />
1412
<div>
1513
\`;
1614
// Exports
@@ -31,13 +29,10 @@ exports[`'preprocess' option should work with the "preprocessor" option #2: erro
3129
3230
exports[`'preprocess' option should work with the "preprocessor" option #2: module 1`] = `
3331
"// Imports
34-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
3532
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png.webp", import.meta.url);
3633
var ___HTML_LOADER_IMPORT_1___ = new URL("./image.png", import.meta.url);
3734
// Module
38-
var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___);
39-
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_1___);
40-
var code = \`<picture><source type="image/webp" srcset="\${___HTML_LOADER_REPLACEMENT_0___}"><img src="\${___HTML_LOADER_REPLACEMENT_1___}"></picture>
35+
var code = \`<picture><source type="image/webp" srcset="\${___HTML_LOADER_IMPORT_0___}"><img src="\${___HTML_LOADER_IMPORT_1___}"></picture>
4136
\`;
4237
// Exports
4338
export default code;"
@@ -54,13 +49,11 @@ exports[`'preprocess' option should work with the "preprocessor" option: errors
5449
5550
exports[`'preprocess' option should work with the "preprocessor" option: module 1`] = `
5651
"// Imports
57-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
5852
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
5953
// Module
60-
var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___);
6154
var code = \`<div>
6255
<p>Alexander Krasnoyarov</p>
63-
<img src="\${___HTML_LOADER_REPLACEMENT_0___}" alt="alt" />
56+
<img src="\${___HTML_LOADER_IMPORT_0___}" alt="alt" />
6457
<div>
6558
\`;
6659
// Exports
@@ -81,13 +74,10 @@ exports[`'preprocess' option should work with the async "preprocessor" function
8174
8275
exports[`'preprocess' option should work with the async "preprocessor" function option #2: module 1`] = `
8376
"// Imports
84-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
8577
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png.webp", import.meta.url);
8678
var ___HTML_LOADER_IMPORT_1___ = new URL("./image.png", import.meta.url);
8779
// Module
88-
var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___);
89-
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_1___);
90-
var code = \`<picture><source type="image/webp" srcset="\${___HTML_LOADER_REPLACEMENT_0___}"><img src="\${___HTML_LOADER_REPLACEMENT_1___}"></picture>
80+
var code = \`<picture><source type="image/webp" srcset="\${___HTML_LOADER_IMPORT_0___}"><img src="\${___HTML_LOADER_IMPORT_1___}"></picture>
9181
\`;
9282
// Exports
9383
export default code;"

‎test/__snapshots__/sources-option.test.js.snap

+2,093-2,560
Large diffs are not rendered by default.

‎test/runtime/__snapshots__/getUrl.test.js.snap

-62
Original file line numberDiff line numberDiff line change
@@ -65,65 +65,3 @@ exports[`getUrl should work 25`] = `""image>image.png""`;
6565
exports[`getUrl should work 26`] = `""image<image.png""`;
6666

6767
exports[`getUrl should work 27`] = `""image\`image.png""`;
68-
69-
exports[`getUrl should work 28`] = `"image.png#hash"`;
70-
71-
exports[`getUrl should work 29`] = `""image image.png#hash""`;
72-
73-
exports[`getUrl should work 30`] = `
74-
""image
75-
image.png#hash""
76-
`;
77-
78-
exports[`getUrl should work 31`] = `""image image.png#hash""`;
79-
80-
exports[`getUrl should work 32`] = `
81-
""image
82-
image.png#hash""
83-
`;
84-
85-
exports[`getUrl should work 33`] = `""image image.png#hash""`;
86-
87-
exports[`getUrl should work 34`] = `""image"image.png#hash""`;
88-
89-
exports[`getUrl should work 35`] = `""image'image.png#hash""`;
90-
91-
exports[`getUrl should work 36`] = `""image=image.png#hash""`;
92-
93-
exports[`getUrl should work 37`] = `""image>image.png#hash""`;
94-
95-
exports[`getUrl should work 38`] = `""image<image.png#hash""`;
96-
97-
exports[`getUrl should work 39`] = `""image\`image.png#hash""`;
98-
99-
exports[`getUrl should work 40`] = `"image.png#hash"`;
100-
101-
exports[`getUrl should work 41`] = `"image image.png#hash"`;
102-
103-
exports[`getUrl should work 42`] = `
104-
"image
105-
image.png#hash"
106-
`;
107-
108-
exports[`getUrl should work 43`] = `"image image.png#hash"`;
109-
110-
exports[`getUrl should work 44`] = `
111-
"image
112-
image.png#hash"
113-
`;
114-
115-
exports[`getUrl should work 45`] = `"image image.png#hash"`;
116-
117-
exports[`getUrl should work 46`] = `"image"image.png#hash"`;
118-
119-
exports[`getUrl should work 47`] = `"image'image.png#hash"`;
120-
121-
exports[`getUrl should work 48`] = `"image=image.png#hash"`;
122-
123-
exports[`getUrl should work 49`] = `"image>image.png#hash"`;
124-
125-
exports[`getUrl should work 50`] = `"image<image.png#hash"`;
126-
127-
exports[`getUrl should work 51`] = `"image\`image.png#hash"`;
128-
129-
exports[`getUrl should work 52`] = `"image.png"`;

‎test/runtime/getUrl.test.js

+12-85
Original file line numberDiff line numberDiff line change
@@ -18,90 +18,17 @@ describe("getUrl", () => {
1818
expect(getUrl("image>image.png")).toMatchSnapshot();
1919
expect(getUrl("image<image.png")).toMatchSnapshot();
2020
expect(getUrl("image`image.png")).toMatchSnapshot();
21-
expect(getUrl("image.png", { maybeNeedQuotes: true })).toMatchSnapshot();
22-
expect(
23-
getUrl("image\timage.png", { maybeNeedQuotes: true }),
24-
).toMatchSnapshot();
25-
expect(
26-
getUrl("image\nimage.png", { maybeNeedQuotes: true }),
27-
).toMatchSnapshot();
28-
expect(
29-
getUrl("image\fimage.png", { maybeNeedQuotes: true }),
30-
).toMatchSnapshot();
31-
expect(
32-
getUrl("image\rimage.png", { maybeNeedQuotes: true }),
33-
).toMatchSnapshot();
34-
expect(
35-
getUrl("image image.png", { maybeNeedQuotes: true }),
36-
).toMatchSnapshot();
37-
expect(
38-
getUrl('image"image.png', { maybeNeedQuotes: true }),
39-
).toMatchSnapshot();
40-
expect(
41-
getUrl("image'image.png", { maybeNeedQuotes: true }),
42-
).toMatchSnapshot();
43-
expect(
44-
getUrl("image=image.png", { maybeNeedQuotes: true }),
45-
).toMatchSnapshot();
46-
expect(
47-
getUrl("image>image.png", { maybeNeedQuotes: true }),
48-
).toMatchSnapshot();
49-
expect(
50-
getUrl("image<image.png", { maybeNeedQuotes: true }),
51-
).toMatchSnapshot();
52-
expect(
53-
getUrl("image`image.png", { maybeNeedQuotes: true }),
54-
).toMatchSnapshot();
55-
expect(
56-
getUrl("image.png", { maybeNeedQuotes: true, hash: "#hash" }),
57-
).toMatchSnapshot();
58-
expect(
59-
getUrl("image\timage.png", { maybeNeedQuotes: true, hash: "#hash" }),
60-
).toMatchSnapshot();
61-
expect(
62-
getUrl("image\nimage.png", { maybeNeedQuotes: true, hash: "#hash" }),
63-
).toMatchSnapshot();
64-
expect(
65-
getUrl("image\fimage.png", { maybeNeedQuotes: true, hash: "#hash" }),
66-
).toMatchSnapshot();
67-
expect(
68-
getUrl("image\rimage.png", { maybeNeedQuotes: true, hash: "#hash" }),
69-
).toMatchSnapshot();
70-
expect(
71-
getUrl("image image.png", { maybeNeedQuotes: true, hash: "#hash" }),
72-
).toMatchSnapshot();
73-
expect(
74-
getUrl('image"image.png', { maybeNeedQuotes: true, hash: "#hash" }),
75-
).toMatchSnapshot();
76-
expect(
77-
getUrl("image'image.png", { maybeNeedQuotes: true, hash: "#hash" }),
78-
).toMatchSnapshot();
79-
expect(
80-
getUrl("image=image.png", { maybeNeedQuotes: true, hash: "#hash" }),
81-
).toMatchSnapshot();
82-
expect(
83-
getUrl("image>image.png", { maybeNeedQuotes: true, hash: "#hash" }),
84-
).toMatchSnapshot();
85-
expect(
86-
getUrl("image<image.png", { maybeNeedQuotes: true, hash: "#hash" }),
87-
).toMatchSnapshot();
88-
expect(
89-
getUrl("image`image.png", { maybeNeedQuotes: true, hash: "#hash" }),
90-
).toMatchSnapshot();
91-
expect(getUrl("image.png", { hash: "#hash" })).toMatchSnapshot();
92-
expect(getUrl("image\timage.png", { hash: "#hash" })).toMatchSnapshot();
93-
expect(getUrl("image\nimage.png", { hash: "#hash" })).toMatchSnapshot();
94-
expect(getUrl("image\fimage.png", { hash: "#hash" })).toMatchSnapshot();
95-
expect(getUrl("image\rimage.png", { hash: "#hash" })).toMatchSnapshot();
96-
expect(getUrl("image image.png", { hash: "#hash" })).toMatchSnapshot();
97-
expect(getUrl('image"image.png', { hash: "#hash" })).toMatchSnapshot();
98-
expect(getUrl("image'image.png", { hash: "#hash" })).toMatchSnapshot();
99-
expect(getUrl("image=image.png", { hash: "#hash" })).toMatchSnapshot();
100-
expect(getUrl("image>image.png", { hash: "#hash" })).toMatchSnapshot();
101-
expect(getUrl("image<image.png", { hash: "#hash" })).toMatchSnapshot();
102-
expect(getUrl("image`image.png", { hash: "#hash" })).toMatchSnapshot();
103-
expect(
104-
getUrl({ default: "image.png", __esModule: true }),
105-
).toMatchSnapshot();
21+
expect(getUrl("image.png", true)).toMatchSnapshot();
22+
expect(getUrl("image\timage.png", true)).toMatchSnapshot();
23+
expect(getUrl("image\nimage.png", true)).toMatchSnapshot();
24+
expect(getUrl("image\fimage.png", true)).toMatchSnapshot();
25+
expect(getUrl("image\rimage.png", true)).toMatchSnapshot();
26+
expect(getUrl("image image.png", true)).toMatchSnapshot();
27+
expect(getUrl('image"image.png', true)).toMatchSnapshot();
28+
expect(getUrl("image'image.png", true)).toMatchSnapshot();
29+
expect(getUrl("image=image.png", true)).toMatchSnapshot();
30+
expect(getUrl("image>image.png", true)).toMatchSnapshot();
31+
expect(getUrl("image<image.png", true)).toMatchSnapshot();
32+
expect(getUrl("image`image.png", true)).toMatchSnapshot();
10633
});
10734
});

0 commit comments

Comments
 (0)
Please sign in to comment.