Skip to content

Commit 8c9dc14

Browse files
author
jbellenger
committed
fix RawModule hashing
fixes #5070
1 parent 316d4b9 commit 8c9dc14

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy