Skip to content

Commit 23742e3

Browse files
fix(url): When using html5Mode and no <base> tag is present, default to '/'
Closes #223
1 parent 095f531 commit 23742e3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/vanilla/browserLocationConfig.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/** @internalapi @module vanilla */ /** */
1+
/** @internalapi @module vanilla */
2+
/** */
23
import { isDefined, isUndefined } from '../common/predicates';
34
import { LocationConfig } from '../common/coreservices';
45

@@ -42,8 +43,11 @@ export class BrowserLocationConfig implements LocationConfig {
4243

4344
private getBaseHref() {
4445
const baseTag: HTMLBaseElement = document.getElementsByTagName('base')[0];
45-
if (!baseTag || !baseTag.href) return location.pathname || '/';
46-
return baseTag.href.replace(/^(https?:)?\/\/[^/]*/, '');
46+
if (baseTag && baseTag.href) {
47+
return baseTag.href.replace(/^(https?:)?\/\/[^/]*/, '');
48+
}
49+
50+
return this._isHtml5 ? '/' : location.pathname || '/';
4751
}
4852

4953
dispose() {}

0 commit comments

Comments
 (0)