Skip to content

Commit

Permalink
[Urthen#54] Add testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
gustaff-weldon committed Feb 22, 2021
1 parent ea62053 commit b1df672
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ CaseSensitivePathsPlugin.prototype.apply = function(compiler) {
// Trim ? off, since some loaders add that to the resource they're attemping to load
return resourcePath.split('?')[0]
// replace escaped \0# with # see: https://github.com/webpack/enhanced-resolve#escaping
.replace(/\u0000#/, '#');
.replace("\0#", '#');
}

const onAfterResolve = (data, done) => {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/name-with-hash/#/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'foo';
1 change: 1 addition & 0 deletions test/fixtures/name-with-hash/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const testModule = require('./#/foo');
16 changes: 16 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ describe('CaseSensitivePathsPlugin', () => {
});
}

it('should handle paths with # correctly', (done) => {
const compiler = webpackCompilerAtDir('name-with-hash');

return compiler.run((err, stats) => {
if (err) done(err);
assert.strictEqual(stats.hasErrors(), false);
assert.strictEqual(stats.hasWarnings(), false);
const jsonStats = stats.toJson();

// check that the plugin produces the correct output
assert.strictEqual(jsonStats.modules[1].name, './#/foo.js');

done();
});
});

// For future reference: This test is somewhat of a race condition, these values seem to work well.
// If this test fails, sometimes just re-running will make it succeed.
it('should handle the deletion of a folder', (done) => {
Expand Down

0 comments on commit b1df672

Please sign in to comment.