Skip to content

Commit e4fbccf

Browse files
clydinBrocco
authored andcommitted
fix(@angular/cli): support empty index base href attribute
1 parent a7a71da commit e4fbccf

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class BaseHrefWebpackPlugin {
2626
} else {
2727
// Replace only href attribute if exists
2828
const modifiedBaseTag = baseTagMatches[0].replace(
29-
/href="\S+"/i, `href="${this.options.baseHref}"`
29+
/href="\S*?"/i, `href="${this.options.baseHref}"`
3030
);
3131
htmlPluginData.html = htmlPluginData.html.replace(baseTagRegex, modifiedBaseTag);
3232
}

Diff for: tests/e2e/tests/build/base-href.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {ng} from '../../utils/process';
2-
import {expectFileToMatch} from '../../utils/fs';
3-
import {updateJsonFile} from '../../utils/project';
1+
import { ng } from '../../utils/process';
2+
import { expectFileToMatch, replaceInFile } from '../../utils/fs';
3+
import { updateJsonFile } from '../../utils/project';
44

55

66
export default function() {
@@ -12,4 +12,7 @@ export default function() {
1212
}))
1313
.then(() => ng('build'))
1414
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/))
15+
.then(() => replaceInFile('src/index.html', 'href="/"', 'href=""'))
16+
.then(() => ng('build'))
17+
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/));
1518
}

0 commit comments

Comments
 (0)