Skip to content

Commit

Permalink
fix(url): When using html5Mode and no <base> tag is present, default …
Browse files Browse the repository at this point in the history
…to '/'

Closes #223
  • Loading branch information
christopherthielen committed Aug 11, 2018
1 parent 095f531 commit 23742e3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/vanilla/browserLocationConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @internalapi @module vanilla */ /** */
/** @internalapi @module vanilla */
/** */
import { isDefined, isUndefined } from '../common/predicates';
import { LocationConfig } from '../common/coreservices';

Expand Down Expand Up @@ -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() {}
Expand Down

0 comments on commit 23742e3

Please sign in to comment.