Skip to content

Commit e146ada

Browse files
authored
Merge pull request #2 from DevWurm/bugfix/unnormalized-asset-paths
Bugfix/unnormalized asset paths
2 parents 984d5f3 + d66f658 commit e146ada

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack-war-plugin",
3-
"version": "1.0.0-beta.1",
3+
"version": "1.0.0-beta.2",
44
"description": "Webpack plugin for bundling build outputs into a WAR archive",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/WebpackWarPlugin.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,36 @@ describe('WebpackWarPlugin', function () {
144144
assert.calledWith(spyAppend, resolve((compiler as any).options.output.path, asset), { name: asset }));
145145
});
146146

147+
it('Should normalize asset paths', function () {
148+
const ArchiverDummy = {
149+
append: (() => null),
150+
pipe: (() => null),
151+
on: (() => null),
152+
finalize: (() => null)
153+
};
154+
const spyAppend = spy(ArchiverDummy, 'append');
155+
156+
const assets = {
157+
'./asset1.txt': {},
158+
'./assets/./asset2.txt': {}
159+
};
160+
161+
compilation.assets = assets;
162+
163+
const plugin = new WebpackWarPlugin({ archiveName: 'Test' });
164+
(plugin as any).archiver = (() => ArchiverDummy);
165+
plugin.apply(compiler);
166+
167+
assert.calledWith(spyAppend,
168+
resolve((compiler as any).options.output.path, Object.getOwnPropertyNames(assets)[0]),
169+
{ name: 'asset1.txt' }
170+
);
171+
assert.calledWith(spyAppend,
172+
resolve((compiler as any).options.output.path, Object.getOwnPropertyNames(assets)[1]),
173+
{ name: 'assets/asset2.txt' }
174+
);
175+
});
176+
147177
it('Should add the WEB-INF folder to the archive', function () {
148178
const ArchiverStub = {
149179
append: (() => null),

src/WebpackWarPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class WebpackWarPlugin implements Plugin {
4242

4343
Object.getOwnPropertyNames(compilation.assets).forEach(asset => {
4444
const srcPath = resolve(outputPath, asset);
45-
archive.append(srcPath, { name: asset });
45+
archive.append(srcPath, { name: normalize(asset) });
4646
});
4747

4848
additionalElements.forEach(({ path, destPath }) => {

0 commit comments

Comments
 (0)