Content-Length: 326361 | pFad | https://snyk.io/redirect/github/webpack/webpack/commit/3da4f3e89dc9732f4266424275f193ea96c14006

A796 Merge pull request #5085 from jbellenger/jbellenger/rawmodule-hash · webpack/webpack@3da4f3e · GitHub
Skip to content

Commit 3da4f3e

Browse files
authored
Merge pull request #5085 from jbellenger/jbellenger/rawmodule-hash
fix RawModule hashing
2 parents 316d4b9 + 8c9dc14 commit 3da4f3e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/RawModule.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@ module.exports = class RawModule extends Module {
4747
return new RawSource(this.sourceStr);
4848
}
4949

50+
updateHash(hash) {
51+
hash.update(this.sourceStr);
52+
super.updateHash(hash);
53+
}
5054
};

test/RawModule.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const RawSource = require("webpack-sources").RawSource;
66
const RequestShortener = require("../lib/RequestShortener");
77
const should = require("should");
88
const path = require("path");
9+
const crypto = require("crypto");
910

1011
describe("RawModule", () => {
1112
let myRawModule;
@@ -62,4 +63,18 @@ describe("RawModule", () => {
6263
}
6364
);
6465
});
66+
67+
describe("updateHash", () => {
68+
it("should include sourceStr in its hash", () => {
69+
const hashModule = (module) => {
70+
const hash = crypto.createHash("sha256");
71+
module.updateHash(hash);
72+
return hash.digest("hex");
73+
};
74+
75+
const hashFoo = hashModule(new RawModule("\"foo\""));
76+
const hashBar = hashModule(new RawModule("\"bar\""));
77+
hashFoo.should.not.equal(hashBar);
78+
});
79+
});
6580
});

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://snyk.io/redirect/github/webpack/webpack/commit/3da4f3e89dc9732f4266424275f193ea96c14006

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy