Skip to content

Commit 2486bf9

Browse files
sendilkumarnhansl
authored andcommitted
fix(@angular/cli): baseHref to accept empty string via cli
1 parent d0cf4a2 commit 2486bf9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.spec.ts

+15
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,19 @@ describe('base href webpack plugin', () => {
6363
});
6464
plugin.apply(compiler);
6565
});
66+
67+
it('should replace href attribute when baseHref is empty', function () {
68+
const plugin = new BaseHrefWebpackPlugin({ baseHref: '' });
69+
70+
const compiler = mockCompiler(oneLineTrim`
71+
<head><base href="/" target="_blank"></head>
72+
<body></body>
73+
`, (_x: any, htmlPluginData: any) => {
74+
expect(htmlPluginData.html).toEqual(oneLineTrim`
75+
<head><base href="" target="_blank"></head>
76+
<body></body>
77+
`);
78+
});
79+
plugin.apply(compiler);
80+
});
6681
});

packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class BaseHrefWebpackPlugin {
77

88
apply(compiler: any): void {
99
// Ignore if baseHref is not passed
10-
if (!this.options.baseHref) {
10+
if (!this.options.baseHref && this.options.baseHref !== '') {
1111
return;
1212
}
1313

0 commit comments

Comments
 (0)