Skip to content

Commit

Permalink
fix(@angular/cli): support empty index base href attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin authored and Brocco committed Feb 15, 2018
1 parent eed5794 commit 214be80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class BaseHrefWebpackPlugin {
} else {
// Replace only href attribute if exists
const modifiedBaseTag = baseTagMatches[0].replace(
/href="\S+"/i, `href="${this.options.baseHref}"`
/href="\S*?"/i, `href="${this.options.baseHref}"`
);
htmlPluginData.html = htmlPluginData.html.replace(baseTagRegex, modifiedBaseTag);
}
Expand Down
9 changes: 6 additions & 3 deletions tests/e2e/tests/build/base-href.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ng} from '../../utils/process';
import {expectFileToMatch} from '../../utils/fs';
import {updateJsonFile} from '../../utils/project';
import { ng } from '../../utils/process';
import { expectFileToMatch, replaceInFile } from '../../utils/fs';
import { updateJsonFile } from '../../utils/project';


export default function() {
Expand All @@ -12,4 +12,7 @@ export default function() {
}))
.then(() => ng('build'))
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/))
.then(() => replaceInFile('src/index.html', 'href="/"', 'href=""'))
.then(() => ng('build'))
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/));
}

0 comments on commit 214be80

Please sign in to comment.