Skip to content

Commit 1008584

Browse files
authored
Merge pull request #222 from IronGeek/issue-221
Fix issue with percent encoded filenames
2 parents 914fdd9 + 2745c3a commit 1008584

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

examples/issue-221/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("ok");

examples/issue-221/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "issue-221",
3+
"description": "Test case for https://github.com/waysact/webpack-subresource-integrity/issues/221",
4+
"version": "1.0.0",
5+
"license": "MIT",
6+
"private": true,
7+
"devDependencies": {
8+
"expect": "^26.6.2",
9+
"html-webpack-plugin": ">= 5.0.0-beta.1",
10+
"nyc": "*",
11+
"webpack": "^5.44.0",
12+
"webpack-cli": "4",
13+
"webpack-subresource-integrity": "*"
14+
}
15+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const { SubresourceIntegrityPlugin } = require("webpack-subresource-integrity");
2+
const HtmlWebpackPlugin = require("html-webpack-plugin");
3+
const expect = require("expect");
4+
5+
module.exports = {
6+
entry: {
7+
"why 1+1=2?": "./index.js",
8+
},
9+
output: {
10+
crossOriginLoading: "anonymous",
11+
},
12+
plugins: [
13+
new SubresourceIntegrityPlugin({
14+
hashFuncNames: ["sha256"],
15+
enabled: true,
16+
}),
17+
new HtmlWebpackPlugin(),
18+
{
19+
apply: (compiler) => {
20+
compiler.hooks.done.tap("wsi-test", (stats) => {
21+
expect(
22+
stats.toJson().assets.find((asset) => asset.name == "why 1+1=2?.js")
23+
).toHaveProperty("integrity");
24+
});
25+
},
26+
},
27+
],
28+
};

webpack-subresource-integrity/src/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export class Plugin {
238238
*/
239239
private hwpAssetPath = (src: string): string => {
240240
assert(this.hwpPublicPath !== null, "Missing HtmlWebpackPlugin publicPath");
241-
return relative(this.hwpPublicPath, src);
241+
return relative(this.hwpPublicPath, decodeURIComponent(src));
242242
};
243243

244244
/**

yarn.lock

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5518,6 +5518,19 @@ __metadata:
55185518
languageName: unknown
55195519
linkType: soft
55205520

5521+
"issue-221@workspace:examples/issue-221":
5522+
version: 0.0.0-use.local
5523+
resolution: "issue-221@workspace:examples/issue-221"
5524+
dependencies:
5525+
expect: ^26.6.2
5526+
html-webpack-plugin: ">= 5.0.0-beta.1"
5527+
nyc: "*"
5528+
webpack: ^5.44.0
5529+
webpack-cli: 4
5530+
webpack-subresource-integrity: "*"
5531+
languageName: unknown
5532+
linkType: soft
5533+
55215534
"istanbul-lib-coverage@npm:^3.0.0, istanbul-lib-coverage@npm:^3.2.0":
55225535
version: 3.2.0
55235536
resolution: "istanbul-lib-coverage@npm:3.2.0"

0 commit comments

Comments
 (0)