From 214be802247230b6a37effa937ac687ad41fde9b Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 8 Feb 2018 12:18:49 -0500 Subject: [PATCH] fix(@angular/cli): support empty index base href attribute --- .../lib/base-href-webpack/base-href-webpack-plugin.ts | 2 +- tests/e2e/tests/build/base-href.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.ts b/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.ts index c7a844926a81..074a0217f354 100644 --- a/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.ts +++ b/packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.ts @@ -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); } diff --git a/tests/e2e/tests/build/base-href.ts b/tests/e2e/tests/build/base-href.ts index 23a1633283dd..6a91cb925edb 100644 --- a/tests/e2e/tests/build/base-href.ts +++ b/tests/e2e/tests/build/base-href.ts @@ -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() { @@ -12,4 +12,7 @@ export default function() { })) .then(() => ng('build')) .then(() => expectFileToMatch('dist/index.html', //)) + .then(() => replaceInFile('src/index.html', 'href="/"', 'href=""')) + .then(() => ng('build')) + .then(() => expectFileToMatch('dist/index.html', //)); }