From 23742e3e02faee73f2f12211910531f92f22b01f Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sat, 11 Aug 2018 11:48:44 -0700 Subject: [PATCH] fix(url): When using html5Mode and no tag is present, default to '/' Closes #223 --- src/vanilla/browserLocationConfig.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/vanilla/browserLocationConfig.ts b/src/vanilla/browserLocationConfig.ts index 2c5ee7f3..4fd1ed89 100644 --- a/src/vanilla/browserLocationConfig.ts +++ b/src/vanilla/browserLocationConfig.ts @@ -1,4 +1,5 @@ -/** @internalapi @module vanilla */ /** */ +/** @internalapi @module vanilla */ +/** */ import { isDefined, isUndefined } from '../common/predicates'; import { LocationConfig } from '../common/coreservices'; @@ -42,8 +43,11 @@ export class BrowserLocationConfig implements LocationConfig { private getBaseHref() { const baseTag: HTMLBaseElement = document.getElementsByTagName('base')[0]; - if (!baseTag || !baseTag.href) return location.pathname || '/'; - return baseTag.href.replace(/^(https?:)?\/\/[^/]*/, ''); + if (baseTag && baseTag.href) { + return baseTag.href.replace(/^(https?:)?\/\/[^/]*/, ''); + } + + return this._isHtml5 ? '/' : location.pathname || '/'; } dispose() {}