1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.BrowserLocationConfig = void 0;
|
4 | var predicates_1 = require("../common/predicates");
|
5 |
|
6 | var BrowserLocationConfig = (function () {
|
7 | function BrowserLocationConfig(router, _isHtml5) {
|
8 | if (_isHtml5 === void 0) { _isHtml5 = false; }
|
9 | this._isHtml5 = _isHtml5;
|
10 | this._baseHref = undefined;
|
11 | this._hashPrefix = '';
|
12 | }
|
13 | BrowserLocationConfig.prototype.port = function () {
|
14 | if (location.port) {
|
15 | return Number(location.port);
|
16 | }
|
17 | return this.protocol() === 'https' ? 443 : 80;
|
18 | };
|
19 | BrowserLocationConfig.prototype.protocol = function () {
|
20 | return location.protocol.replace(/:/g, '');
|
21 | };
|
22 | BrowserLocationConfig.prototype.host = function () {
|
23 | return location.hostname;
|
24 | };
|
25 | BrowserLocationConfig.prototype.html5Mode = function () {
|
26 | return this._isHtml5;
|
27 | };
|
28 | BrowserLocationConfig.prototype.hashPrefix = function (newprefix) {
|
29 | return predicates_1.isDefined(newprefix) ? (this._hashPrefix = newprefix) : this._hashPrefix;
|
30 | };
|
31 | BrowserLocationConfig.prototype.baseHref = function (href) {
|
32 | if (predicates_1.isDefined(href))
|
33 | this._baseHref = href;
|
34 | if (predicates_1.isUndefined(this._baseHref))
|
35 | this._baseHref = this.getBaseHref();
|
36 | return this._baseHref;
|
37 | };
|
38 | BrowserLocationConfig.prototype.getBaseHref = function () {
|
39 | var baseTag = document.getElementsByTagName('base')[0];
|
40 | if (baseTag && baseTag.href) {
|
41 | return baseTag.href.replace(/^([^/:]*:)?\/\/[^/]*/, '');
|
42 | }
|
43 | return this._isHtml5 ? '/' : location.pathname || '/';
|
44 | };
|
45 | BrowserLocationConfig.prototype.dispose = function () { };
|
46 | return BrowserLocationConfig;
|
47 | }());
|
48 | exports.BrowserLocationConfig = BrowserLocationConfig;
|
49 |
|
\ | No newline at end of file |