@angular/common 21.0.0-next.9 → 21.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/_common_module-chunk.mjs +3050 -4380
- package/fesm2022/_common_module-chunk.mjs.map +1 -1
- package/fesm2022/_location-chunk.mjs +392 -588
- package/fesm2022/_location-chunk.mjs.map +1 -1
- package/fesm2022/_module-chunk.mjs +2042 -3001
- package/fesm2022/_module-chunk.mjs.map +1 -1
- package/fesm2022/_platform_navigation-chunk.mjs +30 -16
- package/fesm2022/_platform_navigation-chunk.mjs.map +1 -1
- package/fesm2022/_xhr-chunk.mjs +10 -16
- package/fesm2022/_xhr-chunk.mjs.map +1 -1
- package/fesm2022/common.mjs +1135 -1837
- package/fesm2022/common.mjs.map +1 -1
- package/fesm2022/http-testing.mjs +259 -310
- package/fesm2022/http-testing.mjs.map +1 -1
- package/fesm2022/http.mjs +302 -370
- package/fesm2022/http.mjs.map +1 -1
- package/fesm2022/testing.mjs +596 -552
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/upgrade.mjs +601 -838
- package/fesm2022/upgrade.mjs.map +1 -1
- package/package.json +2 -2
- package/types/_common_module-chunk.d.ts +1 -1
- package/types/_module-chunk.d.ts +33 -1
- package/types/_platform_location-chunk.d.ts +1 -1
- package/types/_xhr-chunk.d.ts +1 -1
- package/types/common.d.ts +34 -4
- package/types/http-testing.d.ts +1 -1
- package/types/http.d.ts +13 -2
- package/types/testing.d.ts +88 -62
- package/types/upgrade.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.0.0-
|
|
2
|
+
* @license Angular v21.0.0-rc.0
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -10,627 +10,431 @@ import { Subject } from 'rxjs';
|
|
|
10
10
|
|
|
11
11
|
let _DOM = null;
|
|
12
12
|
function getDOM() {
|
|
13
|
-
|
|
13
|
+
return _DOM;
|
|
14
14
|
}
|
|
15
15
|
function setRootDomAdapter(adapter) {
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Provides DOM operations in an environment-agnostic way.
|
|
20
|
-
*
|
|
21
|
-
* @security Tread carefully! Interacting with the DOM directly is dangerous and
|
|
22
|
-
* can introduce XSS risks.
|
|
23
|
-
*/
|
|
24
|
-
class DomAdapter {
|
|
16
|
+
_DOM ??= adapter;
|
|
25
17
|
}
|
|
18
|
+
class DomAdapter {}
|
|
26
19
|
|
|
27
|
-
/**
|
|
28
|
-
* This class should not be used directly by an application developer. Instead, use
|
|
29
|
-
* {@link Location}.
|
|
30
|
-
*
|
|
31
|
-
* `PlatformLocation` encapsulates all calls to DOM APIs, which allows the Router to be
|
|
32
|
-
* platform-agnostic.
|
|
33
|
-
* This means that we can have different implementation of `PlatformLocation` for the different
|
|
34
|
-
* platforms that Angular supports. For example, `@angular/platform-browser` provides an
|
|
35
|
-
* implementation specific to the browser environment, while `@angular/platform-server` provides
|
|
36
|
-
* one suitable for use with server-side rendering.
|
|
37
|
-
*
|
|
38
|
-
* The `PlatformLocation` class is used directly by all implementations of {@link LocationStrategy}
|
|
39
|
-
* when they need to interact with the DOM APIs like pushState, popState, etc.
|
|
40
|
-
*
|
|
41
|
-
* {@link LocationStrategy} in turn is used by the {@link Location} service which is used directly
|
|
42
|
-
* by the {@link /api/router/Router Router} in order to navigate between routes. Since all interactions between
|
|
43
|
-
* {@link /api/router/Router Router} /
|
|
44
|
-
* {@link Location} / {@link LocationStrategy} and DOM APIs flow through the `PlatformLocation`
|
|
45
|
-
* class, they are all platform-agnostic.
|
|
46
|
-
*
|
|
47
|
-
* @publicApi
|
|
48
|
-
*/
|
|
49
20
|
class PlatformLocation {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
21
|
+
historyGo(relativePosition) {
|
|
22
|
+
throw new Error(ngDevMode ? 'Not implemented' : '');
|
|
23
|
+
}
|
|
24
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
25
|
+
minVersion: "12.0.0",
|
|
26
|
+
version: "21.0.0-rc.0",
|
|
27
|
+
ngImport: i0,
|
|
28
|
+
type: PlatformLocation,
|
|
29
|
+
deps: [],
|
|
30
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
31
|
+
});
|
|
32
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
33
|
+
minVersion: "12.0.0",
|
|
34
|
+
version: "21.0.0-rc.0",
|
|
35
|
+
ngImport: i0,
|
|
36
|
+
type: PlatformLocation,
|
|
37
|
+
providedIn: 'platform',
|
|
38
|
+
useFactory: () => inject(BrowserPlatformLocation)
|
|
39
|
+
});
|
|
55
40
|
}
|
|
56
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
41
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
42
|
+
minVersion: "12.0.0",
|
|
43
|
+
version: "21.0.0-rc.0",
|
|
44
|
+
ngImport: i0,
|
|
45
|
+
type: PlatformLocation,
|
|
46
|
+
decorators: [{
|
|
47
|
+
type: Injectable,
|
|
48
|
+
args: [{
|
|
49
|
+
providedIn: 'platform',
|
|
50
|
+
useFactory: () => inject(BrowserPlatformLocation)
|
|
51
|
+
}]
|
|
52
|
+
}]
|
|
53
|
+
});
|
|
66
54
|
const LOCATION_INITIALIZED = new InjectionToken(typeof ngDevMode !== undefined && ngDevMode ? 'Location Initialized' : '');
|
|
67
|
-
/**
|
|
68
|
-
* `PlatformLocation` encapsulates all of the direct calls to platform APIs.
|
|
69
|
-
* This class should not be used directly by an application developer. Instead, use
|
|
70
|
-
* {@link Location}.
|
|
71
|
-
*
|
|
72
|
-
* @publicApi
|
|
73
|
-
*/
|
|
74
55
|
class BrowserPlatformLocation extends PlatformLocation {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
56
|
+
_location;
|
|
57
|
+
_history;
|
|
58
|
+
_doc = inject(DOCUMENT);
|
|
59
|
+
constructor() {
|
|
60
|
+
super();
|
|
61
|
+
this._location = window.location;
|
|
62
|
+
this._history = window.history;
|
|
63
|
+
}
|
|
64
|
+
getBaseHrefFromDOM() {
|
|
65
|
+
return getDOM().getBaseHref(this._doc);
|
|
66
|
+
}
|
|
67
|
+
onPopState(fn) {
|
|
68
|
+
const window = getDOM().getGlobalEventTarget(this._doc, 'window');
|
|
69
|
+
window.addEventListener('popstate', fn, false);
|
|
70
|
+
return () => window.removeEventListener('popstate', fn);
|
|
71
|
+
}
|
|
72
|
+
onHashChange(fn) {
|
|
73
|
+
const window = getDOM().getGlobalEventTarget(this._doc, 'window');
|
|
74
|
+
window.addEventListener('hashchange', fn, false);
|
|
75
|
+
return () => window.removeEventListener('hashchange', fn);
|
|
76
|
+
}
|
|
77
|
+
get href() {
|
|
78
|
+
return this._location.href;
|
|
79
|
+
}
|
|
80
|
+
get protocol() {
|
|
81
|
+
return this._location.protocol;
|
|
82
|
+
}
|
|
83
|
+
get hostname() {
|
|
84
|
+
return this._location.hostname;
|
|
85
|
+
}
|
|
86
|
+
get port() {
|
|
87
|
+
return this._location.port;
|
|
88
|
+
}
|
|
89
|
+
get pathname() {
|
|
90
|
+
return this._location.pathname;
|
|
91
|
+
}
|
|
92
|
+
get search() {
|
|
93
|
+
return this._location.search;
|
|
94
|
+
}
|
|
95
|
+
get hash() {
|
|
96
|
+
return this._location.hash;
|
|
97
|
+
}
|
|
98
|
+
set pathname(newPath) {
|
|
99
|
+
this._location.pathname = newPath;
|
|
100
|
+
}
|
|
101
|
+
pushState(state, title, url) {
|
|
102
|
+
this._history.pushState(state, title, url);
|
|
103
|
+
}
|
|
104
|
+
replaceState(state, title, url) {
|
|
105
|
+
this._history.replaceState(state, title, url);
|
|
106
|
+
}
|
|
107
|
+
forward() {
|
|
108
|
+
this._history.forward();
|
|
109
|
+
}
|
|
110
|
+
back() {
|
|
111
|
+
this._history.back();
|
|
112
|
+
}
|
|
113
|
+
historyGo(relativePosition = 0) {
|
|
114
|
+
this._history.go(relativePosition);
|
|
115
|
+
}
|
|
116
|
+
getState() {
|
|
117
|
+
return this._history.state;
|
|
118
|
+
}
|
|
119
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
120
|
+
minVersion: "12.0.0",
|
|
121
|
+
version: "21.0.0-rc.0",
|
|
122
|
+
ngImport: i0,
|
|
123
|
+
type: BrowserPlatformLocation,
|
|
124
|
+
deps: [],
|
|
125
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
126
|
+
});
|
|
127
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
128
|
+
minVersion: "12.0.0",
|
|
129
|
+
version: "21.0.0-rc.0",
|
|
130
|
+
ngImport: i0,
|
|
131
|
+
type: BrowserPlatformLocation,
|
|
132
|
+
providedIn: 'platform',
|
|
133
|
+
useFactory: () => new BrowserPlatformLocation()
|
|
134
|
+
});
|
|
140
135
|
}
|
|
141
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
136
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
137
|
+
minVersion: "12.0.0",
|
|
138
|
+
version: "21.0.0-rc.0",
|
|
139
|
+
ngImport: i0,
|
|
140
|
+
type: BrowserPlatformLocation,
|
|
141
|
+
decorators: [{
|
|
142
|
+
type: Injectable,
|
|
143
|
+
args: [{
|
|
144
|
+
providedIn: 'platform',
|
|
145
|
+
useFactory: () => new BrowserPlatformLocation()
|
|
146
|
+
}]
|
|
147
|
+
}],
|
|
148
|
+
ctorParameters: () => []
|
|
149
|
+
});
|
|
148
150
|
|
|
149
|
-
/**
|
|
150
|
-
* Joins two parts of a URL with a slash if needed.
|
|
151
|
-
*
|
|
152
|
-
* @param start URL string
|
|
153
|
-
* @param end URL string
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* @returns The joined URL string.
|
|
157
|
-
*/
|
|
158
151
|
function joinWithSlash(start, end) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// If `start` ends with a slash, remove the leading slash from `end`.
|
|
166
|
-
if (start.endsWith('/')) {
|
|
167
|
-
return end.startsWith('/') ? start + end.slice(1) : start + end;
|
|
168
|
-
}
|
|
169
|
-
// If `start` doesn't end with a slash, add one if `end` doesn't start with a slash.
|
|
170
|
-
return end.startsWith('/') ? start + end : `${start}/${end}`;
|
|
152
|
+
if (!start) return end;
|
|
153
|
+
if (!end) return start;
|
|
154
|
+
if (start.endsWith('/')) {
|
|
155
|
+
return end.startsWith('/') ? start + end.slice(1) : start + end;
|
|
156
|
+
}
|
|
157
|
+
return end.startsWith('/') ? start + end : `${start}/${end}`;
|
|
171
158
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Removes a trailing slash from a URL string if needed.
|
|
174
|
-
* Looks for the first occurrence of either `#`, `?`, or the end of the
|
|
175
|
-
* line as `/` characters and removes the trailing slash if one exists.
|
|
176
|
-
*
|
|
177
|
-
* @param url URL string.
|
|
178
|
-
*
|
|
179
|
-
* @returns The URL string, modified if needed.
|
|
180
|
-
*/
|
|
181
159
|
function stripTrailingSlash(url) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const pathEndIdx = url.search(/#|\?|$/);
|
|
185
|
-
// Check if the character before `pathEndIdx` is a trailing slash.
|
|
186
|
-
// If it is, remove the trailing slash and return the modified URL.
|
|
187
|
-
// Otherwise, return the URL as is.
|
|
188
|
-
return url[pathEndIdx - 1] === '/' ? url.slice(0, pathEndIdx - 1) + url.slice(pathEndIdx) : url;
|
|
160
|
+
const pathEndIdx = url.search(/#|\?|$/);
|
|
161
|
+
return url[pathEndIdx - 1] === '/' ? url.slice(0, pathEndIdx - 1) + url.slice(pathEndIdx) : url;
|
|
189
162
|
}
|
|
190
|
-
/**
|
|
191
|
-
* Normalizes URL parameters by prepending with `?` if needed.
|
|
192
|
-
*
|
|
193
|
-
* @param params String of URL parameters.
|
|
194
|
-
*
|
|
195
|
-
* @returns The normalized URL parameters string.
|
|
196
|
-
*/
|
|
197
163
|
function normalizeQueryParams(params) {
|
|
198
|
-
|
|
164
|
+
return params && params[0] !== '?' ? `?${params}` : params;
|
|
199
165
|
}
|
|
200
166
|
|
|
201
|
-
/**
|
|
202
|
-
* Enables the `Location` service to read route state from the browser's URL.
|
|
203
|
-
* Angular provides two strategies:
|
|
204
|
-
* `HashLocationStrategy` and `PathLocationStrategy`.
|
|
205
|
-
*
|
|
206
|
-
* Applications should use the `Router` or `Location` services to
|
|
207
|
-
* interact with application route state.
|
|
208
|
-
*
|
|
209
|
-
* For instance, `HashLocationStrategy` produces URLs like
|
|
210
|
-
* <code class="no-auto-link">http://example.com/#/foo</code>,
|
|
211
|
-
* and `PathLocationStrategy` produces
|
|
212
|
-
* <code class="no-auto-link">http://example.com/foo</code> as an equivalent URL.
|
|
213
|
-
*
|
|
214
|
-
* See these two classes for more.
|
|
215
|
-
*
|
|
216
|
-
* @publicApi
|
|
217
|
-
*/
|
|
218
167
|
class LocationStrategy {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
168
|
+
historyGo(relativePosition) {
|
|
169
|
+
throw new Error(ngDevMode ? 'Not implemented' : '');
|
|
170
|
+
}
|
|
171
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
172
|
+
minVersion: "12.0.0",
|
|
173
|
+
version: "21.0.0-rc.0",
|
|
174
|
+
ngImport: i0,
|
|
175
|
+
type: LocationStrategy,
|
|
176
|
+
deps: [],
|
|
177
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
178
|
+
});
|
|
179
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
180
|
+
minVersion: "12.0.0",
|
|
181
|
+
version: "21.0.0-rc.0",
|
|
182
|
+
ngImport: i0,
|
|
183
|
+
type: LocationStrategy,
|
|
184
|
+
providedIn: 'root',
|
|
185
|
+
useFactory: () => inject(PathLocationStrategy)
|
|
186
|
+
});
|
|
224
187
|
}
|
|
225
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
* with a base href value, so that the DI framework can supply the dependency anywhere in the app.
|
|
239
|
-
*
|
|
240
|
-
* ```ts
|
|
241
|
-
* import {NgModule} from '@angular/core';
|
|
242
|
-
* import {APP_BASE_HREF} from '@angular/common';
|
|
243
|
-
*
|
|
244
|
-
* @NgModule({
|
|
245
|
-
* providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]
|
|
246
|
-
* })
|
|
247
|
-
* class AppModule {}
|
|
248
|
-
* ```
|
|
249
|
-
*
|
|
250
|
-
* @publicApi
|
|
251
|
-
*/
|
|
188
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
189
|
+
minVersion: "12.0.0",
|
|
190
|
+
version: "21.0.0-rc.0",
|
|
191
|
+
ngImport: i0,
|
|
192
|
+
type: LocationStrategy,
|
|
193
|
+
decorators: [{
|
|
194
|
+
type: Injectable,
|
|
195
|
+
args: [{
|
|
196
|
+
providedIn: 'root',
|
|
197
|
+
useFactory: () => inject(PathLocationStrategy)
|
|
198
|
+
}]
|
|
199
|
+
}]
|
|
200
|
+
});
|
|
252
201
|
const APP_BASE_HREF = new InjectionToken(typeof ngDevMode !== undefined && ngDevMode ? 'appBaseHref' : '');
|
|
253
|
-
/**
|
|
254
|
-
* @description
|
|
255
|
-
* A {@link LocationStrategy} used to configure the {@link Location} service to
|
|
256
|
-
* represent its state in the
|
|
257
|
-
* [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the
|
|
258
|
-
* browser's URL.
|
|
259
|
-
*
|
|
260
|
-
* If you're using `PathLocationStrategy`, you may provide a {@link APP_BASE_HREF}
|
|
261
|
-
* or add a `<base href>` element to the document to override the default.
|
|
262
|
-
*
|
|
263
|
-
* For instance, if you provide an `APP_BASE_HREF` of `'/my/app/'` and call
|
|
264
|
-
* `location.go('/foo')`, the browser's URL will become
|
|
265
|
-
* `example.com/my/app/foo`. To ensure all relative URIs resolve correctly,
|
|
266
|
-
* the `<base href>` and/or `APP_BASE_HREF` should end with a `/`.
|
|
267
|
-
*
|
|
268
|
-
* Similarly, if you add `<base href='/my/app/'/>` to the document and call
|
|
269
|
-
* `location.go('/foo')`, the browser's URL will become
|
|
270
|
-
* `example.com/my/app/foo`.
|
|
271
|
-
*
|
|
272
|
-
* Note that when using `PathLocationStrategy`, neither the query nor
|
|
273
|
-
* the fragment in the `<base href>` will be preserved, as outlined
|
|
274
|
-
* by the [RFC](https://tools.ietf.org/html/rfc3986#section-5.2.2).
|
|
275
|
-
*
|
|
276
|
-
* @usageNotes
|
|
277
|
-
*
|
|
278
|
-
* ### Example
|
|
279
|
-
*
|
|
280
|
-
* {@example common/location/ts/path_location_component.ts region='LocationComponent'}
|
|
281
|
-
*
|
|
282
|
-
* @publicApi
|
|
283
|
-
*/
|
|
284
202
|
class PathLocationStrategy extends LocationStrategy {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
203
|
+
_platformLocation;
|
|
204
|
+
_baseHref;
|
|
205
|
+
_removeListenerFns = [];
|
|
206
|
+
constructor(_platformLocation, href) {
|
|
207
|
+
super();
|
|
208
|
+
this._platformLocation = _platformLocation;
|
|
209
|
+
this._baseHref = href ?? this._platformLocation.getBaseHrefFromDOM() ?? inject(DOCUMENT).location?.origin ?? '';
|
|
210
|
+
}
|
|
211
|
+
ngOnDestroy() {
|
|
212
|
+
while (this._removeListenerFns.length) {
|
|
213
|
+
this._removeListenerFns.pop()();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
onPopState(fn) {
|
|
217
|
+
this._removeListenerFns.push(this._platformLocation.onPopState(fn), this._platformLocation.onHashChange(fn));
|
|
218
|
+
}
|
|
219
|
+
getBaseHref() {
|
|
220
|
+
return this._baseHref;
|
|
221
|
+
}
|
|
222
|
+
prepareExternalUrl(internal) {
|
|
223
|
+
return joinWithSlash(this._baseHref, internal);
|
|
224
|
+
}
|
|
225
|
+
path(includeHash = false) {
|
|
226
|
+
const pathname = this._platformLocation.pathname + normalizeQueryParams(this._platformLocation.search);
|
|
227
|
+
const hash = this._platformLocation.hash;
|
|
228
|
+
return hash && includeHash ? `${pathname}${hash}` : pathname;
|
|
229
|
+
}
|
|
230
|
+
pushState(state, title, url, queryParams) {
|
|
231
|
+
const externalUrl = this.prepareExternalUrl(url + normalizeQueryParams(queryParams));
|
|
232
|
+
this._platformLocation.pushState(state, title, externalUrl);
|
|
233
|
+
}
|
|
234
|
+
replaceState(state, title, url, queryParams) {
|
|
235
|
+
const externalUrl = this.prepareExternalUrl(url + normalizeQueryParams(queryParams));
|
|
236
|
+
this._platformLocation.replaceState(state, title, externalUrl);
|
|
237
|
+
}
|
|
238
|
+
forward() {
|
|
239
|
+
this._platformLocation.forward();
|
|
240
|
+
}
|
|
241
|
+
back() {
|
|
242
|
+
this._platformLocation.back();
|
|
243
|
+
}
|
|
244
|
+
getState() {
|
|
245
|
+
return this._platformLocation.getState();
|
|
246
|
+
}
|
|
247
|
+
historyGo(relativePosition = 0) {
|
|
248
|
+
this._platformLocation.historyGo?.(relativePosition);
|
|
249
|
+
}
|
|
250
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
251
|
+
minVersion: "12.0.0",
|
|
252
|
+
version: "21.0.0-rc.0",
|
|
253
|
+
ngImport: i0,
|
|
254
|
+
type: PathLocationStrategy,
|
|
255
|
+
deps: [{
|
|
256
|
+
token: PlatformLocation
|
|
257
|
+
}, {
|
|
258
|
+
token: APP_BASE_HREF,
|
|
259
|
+
optional: true
|
|
260
|
+
}],
|
|
261
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
262
|
+
});
|
|
263
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
264
|
+
minVersion: "12.0.0",
|
|
265
|
+
version: "21.0.0-rc.0",
|
|
266
|
+
ngImport: i0,
|
|
267
|
+
type: PathLocationStrategy,
|
|
268
|
+
providedIn: 'root'
|
|
269
|
+
});
|
|
339
270
|
}
|
|
340
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
271
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
272
|
+
minVersion: "12.0.0",
|
|
273
|
+
version: "21.0.0-rc.0",
|
|
274
|
+
ngImport: i0,
|
|
275
|
+
type: PathLocationStrategy,
|
|
276
|
+
decorators: [{
|
|
277
|
+
type: Injectable,
|
|
278
|
+
args: [{
|
|
279
|
+
providedIn: 'root'
|
|
280
|
+
}]
|
|
281
|
+
}],
|
|
282
|
+
ctorParameters: () => [{
|
|
283
|
+
type: PlatformLocation
|
|
284
|
+
}, {
|
|
285
|
+
type: undefined,
|
|
286
|
+
decorators: [{
|
|
287
|
+
type: Optional
|
|
288
|
+
}, {
|
|
289
|
+
type: Inject,
|
|
290
|
+
args: [APP_BASE_HREF]
|
|
291
|
+
}]
|
|
292
|
+
}]
|
|
293
|
+
});
|
|
349
294
|
|
|
350
|
-
/**
|
|
351
|
-
* @description
|
|
352
|
-
*
|
|
353
|
-
* A service that applications can use to interact with a browser's URL.
|
|
354
|
-
*
|
|
355
|
-
* Depending on the `LocationStrategy` used, `Location` persists
|
|
356
|
-
* to the URL's path or the URL's hash segment.
|
|
357
|
-
*
|
|
358
|
-
* @usageNotes
|
|
359
|
-
*
|
|
360
|
-
* It's better to use the `Router.navigate()` service to trigger route changes. Use
|
|
361
|
-
* `Location` only if you need to interact with or create normalized URLs outside of
|
|
362
|
-
* routing.
|
|
363
|
-
*
|
|
364
|
-
* `Location` is responsible for normalizing the URL against the application's base href.
|
|
365
|
-
* A normalized URL is absolute from the URL host, includes the application's base href, and has no
|
|
366
|
-
* trailing slash:
|
|
367
|
-
* - `/my/app/user/123` is normalized
|
|
368
|
-
* - `my/app/user/123` **is not** normalized
|
|
369
|
-
* - `/my/app/user/123/` **is not** normalized
|
|
370
|
-
*
|
|
371
|
-
* ### Example
|
|
372
|
-
*
|
|
373
|
-
* {@example common/location/ts/path_location_component.ts region='LocationComponent'}
|
|
374
|
-
*
|
|
375
|
-
* @publicApi
|
|
376
|
-
*/
|
|
377
295
|
class Location {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
this.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
296
|
+
_subject = new Subject();
|
|
297
|
+
_basePath;
|
|
298
|
+
_locationStrategy;
|
|
299
|
+
_urlChangeListeners = [];
|
|
300
|
+
_urlChangeSubscription = null;
|
|
301
|
+
constructor(locationStrategy) {
|
|
302
|
+
this._locationStrategy = locationStrategy;
|
|
303
|
+
const baseHref = this._locationStrategy.getBaseHref();
|
|
304
|
+
this._basePath = _stripOrigin(stripTrailingSlash(_stripIndexHtml(baseHref)));
|
|
305
|
+
this._locationStrategy.onPopState(ev => {
|
|
306
|
+
this._subject.next({
|
|
307
|
+
'url': this.path(true),
|
|
308
|
+
'pop': true,
|
|
309
|
+
'state': ev.state,
|
|
310
|
+
'type': ev.type
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
ngOnDestroy() {
|
|
315
|
+
this._urlChangeSubscription?.unsubscribe();
|
|
316
|
+
this._urlChangeListeners = [];
|
|
317
|
+
}
|
|
318
|
+
path(includeHash = false) {
|
|
319
|
+
return this.normalize(this._locationStrategy.path(includeHash));
|
|
320
|
+
}
|
|
321
|
+
getState() {
|
|
322
|
+
return this._locationStrategy.getState();
|
|
323
|
+
}
|
|
324
|
+
isCurrentPathEqualTo(path, query = '') {
|
|
325
|
+
return this.path() == this.normalize(path + normalizeQueryParams(query));
|
|
326
|
+
}
|
|
327
|
+
normalize(url) {
|
|
328
|
+
return Location.stripTrailingSlash(_stripBasePath(this._basePath, _stripIndexHtml(url)));
|
|
329
|
+
}
|
|
330
|
+
prepareExternalUrl(url) {
|
|
331
|
+
if (url && url[0] !== '/') {
|
|
332
|
+
url = '/' + url;
|
|
333
|
+
}
|
|
334
|
+
return this._locationStrategy.prepareExternalUrl(url);
|
|
335
|
+
}
|
|
336
|
+
go(path, query = '', state = null) {
|
|
337
|
+
this._locationStrategy.pushState(state, '', path, query);
|
|
338
|
+
this._notifyUrlChangeListeners(this.prepareExternalUrl(path + normalizeQueryParams(query)), state);
|
|
339
|
+
}
|
|
340
|
+
replaceState(path, query = '', state = null) {
|
|
341
|
+
this._locationStrategy.replaceState(state, '', path, query);
|
|
342
|
+
this._notifyUrlChangeListeners(this.prepareExternalUrl(path + normalizeQueryParams(query)), state);
|
|
343
|
+
}
|
|
344
|
+
forward() {
|
|
345
|
+
this._locationStrategy.forward();
|
|
346
|
+
}
|
|
347
|
+
back() {
|
|
348
|
+
this._locationStrategy.back();
|
|
349
|
+
}
|
|
350
|
+
historyGo(relativePosition = 0) {
|
|
351
|
+
this._locationStrategy.historyGo?.(relativePosition);
|
|
352
|
+
}
|
|
353
|
+
onUrlChange(fn) {
|
|
354
|
+
this._urlChangeListeners.push(fn);
|
|
355
|
+
this._urlChangeSubscription ??= this.subscribe(v => {
|
|
356
|
+
this._notifyUrlChangeListeners(v.url, v.state);
|
|
357
|
+
});
|
|
358
|
+
return () => {
|
|
359
|
+
const fnIndex = this._urlChangeListeners.indexOf(fn);
|
|
360
|
+
this._urlChangeListeners.splice(fnIndex, 1);
|
|
361
|
+
if (this._urlChangeListeners.length === 0) {
|
|
409
362
|
this._urlChangeSubscription?.unsubscribe();
|
|
410
|
-
this.
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
*
|
|
446
|
-
* @param url String representing a URL.
|
|
447
|
-
*
|
|
448
|
-
* @returns The normalized URL string.
|
|
449
|
-
*/
|
|
450
|
-
normalize(url) {
|
|
451
|
-
return Location.stripTrailingSlash(_stripBasePath(this._basePath, _stripIndexHtml(url)));
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Normalizes an external URL path.
|
|
455
|
-
* If the given URL doesn't begin with a leading slash (`'/'`), adds one
|
|
456
|
-
* before normalizing. Adds a hash if `HashLocationStrategy` is
|
|
457
|
-
* in use, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
|
|
458
|
-
*
|
|
459
|
-
* @param url String representing a URL.
|
|
460
|
-
*
|
|
461
|
-
* @returns A normalized platform-specific URL.
|
|
462
|
-
*/
|
|
463
|
-
prepareExternalUrl(url) {
|
|
464
|
-
if (url && url[0] !== '/') {
|
|
465
|
-
url = '/' + url;
|
|
466
|
-
}
|
|
467
|
-
return this._locationStrategy.prepareExternalUrl(url);
|
|
468
|
-
}
|
|
469
|
-
// TODO: rename this method to pushState
|
|
470
|
-
/**
|
|
471
|
-
* Changes the browser's URL to a normalized version of a given URL, and pushes a
|
|
472
|
-
* new item onto the platform's history.
|
|
473
|
-
*
|
|
474
|
-
* @param path URL path to normalize.
|
|
475
|
-
* @param query Query parameters.
|
|
476
|
-
* @param state Location history state.
|
|
477
|
-
*
|
|
478
|
-
*/
|
|
479
|
-
go(path, query = '', state = null) {
|
|
480
|
-
this._locationStrategy.pushState(state, '', path, query);
|
|
481
|
-
this._notifyUrlChangeListeners(this.prepareExternalUrl(path + normalizeQueryParams(query)), state);
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Changes the browser's URL to a normalized version of the given URL, and replaces
|
|
485
|
-
* the top item on the platform's history stack.
|
|
486
|
-
*
|
|
487
|
-
* @param path URL path to normalize.
|
|
488
|
-
* @param query Query parameters.
|
|
489
|
-
* @param state Location history state.
|
|
490
|
-
*/
|
|
491
|
-
replaceState(path, query = '', state = null) {
|
|
492
|
-
this._locationStrategy.replaceState(state, '', path, query);
|
|
493
|
-
this._notifyUrlChangeListeners(this.prepareExternalUrl(path + normalizeQueryParams(query)), state);
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Navigates forward in the platform's history.
|
|
497
|
-
*/
|
|
498
|
-
forward() {
|
|
499
|
-
this._locationStrategy.forward();
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* Navigates back in the platform's history.
|
|
503
|
-
*/
|
|
504
|
-
back() {
|
|
505
|
-
this._locationStrategy.back();
|
|
506
|
-
}
|
|
507
|
-
/**
|
|
508
|
-
* Navigate to a specific page from session history, identified by its relative position to the
|
|
509
|
-
* current page.
|
|
510
|
-
*
|
|
511
|
-
* @param relativePosition Position of the target page in the history relative to the current
|
|
512
|
-
* page.
|
|
513
|
-
* A negative value moves backwards, a positive value moves forwards, e.g. `location.historyGo(2)`
|
|
514
|
-
* moves forward two pages and `location.historyGo(-2)` moves back two pages. When we try to go
|
|
515
|
-
* beyond what's stored in the history session, we stay in the current page. Same behaviour occurs
|
|
516
|
-
* when `relativePosition` equals 0.
|
|
517
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/History_API#Moving_to_a_specific_point_in_history
|
|
518
|
-
*/
|
|
519
|
-
historyGo(relativePosition = 0) {
|
|
520
|
-
this._locationStrategy.historyGo?.(relativePosition);
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* Registers a URL change listener. Use to catch updates performed by the Angular
|
|
524
|
-
* framework that are not detectible through "popstate" or "hashchange" events.
|
|
525
|
-
*
|
|
526
|
-
* @param fn The change handler function, which take a URL and a location history state.
|
|
527
|
-
* @returns A function that, when executed, unregisters a URL change listener.
|
|
528
|
-
*/
|
|
529
|
-
onUrlChange(fn) {
|
|
530
|
-
this._urlChangeListeners.push(fn);
|
|
531
|
-
this._urlChangeSubscription ??= this.subscribe((v) => {
|
|
532
|
-
this._notifyUrlChangeListeners(v.url, v.state);
|
|
533
|
-
});
|
|
534
|
-
return () => {
|
|
535
|
-
const fnIndex = this._urlChangeListeners.indexOf(fn);
|
|
536
|
-
this._urlChangeListeners.splice(fnIndex, 1);
|
|
537
|
-
if (this._urlChangeListeners.length === 0) {
|
|
538
|
-
this._urlChangeSubscription?.unsubscribe();
|
|
539
|
-
this._urlChangeSubscription = null;
|
|
540
|
-
}
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
/** @internal */
|
|
544
|
-
_notifyUrlChangeListeners(url = '', state) {
|
|
545
|
-
this._urlChangeListeners.forEach((fn) => fn(url, state));
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* Subscribes to the platform's `popState` events.
|
|
549
|
-
*
|
|
550
|
-
* Note: `Location.go()` does not trigger the `popState` event in the browser. Use
|
|
551
|
-
* `Location.onUrlChange()` to subscribe to URL changes instead.
|
|
552
|
-
*
|
|
553
|
-
* @param value Event that is triggered when the state history changes.
|
|
554
|
-
* @param exception The exception to throw.
|
|
555
|
-
*
|
|
556
|
-
* @see [onpopstate](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate)
|
|
557
|
-
*
|
|
558
|
-
* @returns Subscribed events.
|
|
559
|
-
*/
|
|
560
|
-
subscribe(onNext, onThrow, onReturn) {
|
|
561
|
-
return this._subject.subscribe({
|
|
562
|
-
next: onNext,
|
|
563
|
-
error: onThrow ?? undefined,
|
|
564
|
-
complete: onReturn ?? undefined,
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
/**
|
|
568
|
-
* Normalizes URL parameters by prepending with `?` if needed.
|
|
569
|
-
*
|
|
570
|
-
* @param params String of URL parameters.
|
|
571
|
-
*
|
|
572
|
-
* @returns The normalized URL parameters string.
|
|
573
|
-
*/
|
|
574
|
-
static normalizeQueryParams = normalizeQueryParams;
|
|
575
|
-
/**
|
|
576
|
-
* Joins two parts of a URL with a slash if needed.
|
|
577
|
-
*
|
|
578
|
-
* @param start URL string
|
|
579
|
-
* @param end URL string
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
* @returns The joined URL string.
|
|
583
|
-
*/
|
|
584
|
-
static joinWithSlash = joinWithSlash;
|
|
585
|
-
/**
|
|
586
|
-
* Removes a trailing slash from a URL string if needed.
|
|
587
|
-
* Looks for the first occurrence of either `#`, `?`, or the end of the
|
|
588
|
-
* line as `/` characters and removes the trailing slash if one exists.
|
|
589
|
-
*
|
|
590
|
-
* @param url URL string.
|
|
591
|
-
*
|
|
592
|
-
* @returns The URL string, modified if needed.
|
|
593
|
-
*/
|
|
594
|
-
static stripTrailingSlash = stripTrailingSlash;
|
|
595
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0-next.9", ngImport: i0, type: Location, deps: [{ token: LocationStrategy }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
596
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0-next.9", ngImport: i0, type: Location, providedIn: 'root', useFactory: createLocation });
|
|
363
|
+
this._urlChangeSubscription = null;
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
_notifyUrlChangeListeners(url = '', state) {
|
|
368
|
+
this._urlChangeListeners.forEach(fn => fn(url, state));
|
|
369
|
+
}
|
|
370
|
+
subscribe(onNext, onThrow, onReturn) {
|
|
371
|
+
return this._subject.subscribe({
|
|
372
|
+
next: onNext,
|
|
373
|
+
error: onThrow ?? undefined,
|
|
374
|
+
complete: onReturn ?? undefined
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
static normalizeQueryParams = normalizeQueryParams;
|
|
378
|
+
static joinWithSlash = joinWithSlash;
|
|
379
|
+
static stripTrailingSlash = stripTrailingSlash;
|
|
380
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
381
|
+
minVersion: "12.0.0",
|
|
382
|
+
version: "21.0.0-rc.0",
|
|
383
|
+
ngImport: i0,
|
|
384
|
+
type: Location,
|
|
385
|
+
deps: [{
|
|
386
|
+
token: LocationStrategy
|
|
387
|
+
}],
|
|
388
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
389
|
+
});
|
|
390
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
391
|
+
minVersion: "12.0.0",
|
|
392
|
+
version: "21.0.0-rc.0",
|
|
393
|
+
ngImport: i0,
|
|
394
|
+
type: Location,
|
|
395
|
+
providedIn: 'root',
|
|
396
|
+
useFactory: createLocation
|
|
397
|
+
});
|
|
597
398
|
}
|
|
598
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
399
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
400
|
+
minVersion: "12.0.0",
|
|
401
|
+
version: "21.0.0-rc.0",
|
|
402
|
+
ngImport: i0,
|
|
403
|
+
type: Location,
|
|
404
|
+
decorators: [{
|
|
405
|
+
type: Injectable,
|
|
406
|
+
args: [{
|
|
407
|
+
providedIn: 'root',
|
|
408
|
+
useFactory: createLocation
|
|
409
|
+
}]
|
|
410
|
+
}],
|
|
411
|
+
ctorParameters: () => [{
|
|
412
|
+
type: LocationStrategy
|
|
413
|
+
}]
|
|
414
|
+
});
|
|
606
415
|
function createLocation() {
|
|
607
|
-
|
|
416
|
+
return new Location(__inject(LocationStrategy));
|
|
608
417
|
}
|
|
609
418
|
function _stripBasePath(basePath, url) {
|
|
610
|
-
|
|
611
|
-
return url;
|
|
612
|
-
}
|
|
613
|
-
const strippedUrl = url.substring(basePath.length);
|
|
614
|
-
if (strippedUrl === '' || ['/', ';', '?', '#'].includes(strippedUrl[0])) {
|
|
615
|
-
return strippedUrl;
|
|
616
|
-
}
|
|
419
|
+
if (!basePath || !url.startsWith(basePath)) {
|
|
617
420
|
return url;
|
|
421
|
+
}
|
|
422
|
+
const strippedUrl = url.substring(basePath.length);
|
|
423
|
+
if (strippedUrl === '' || ['/', ';', '?', '#'].includes(strippedUrl[0])) {
|
|
424
|
+
return strippedUrl;
|
|
425
|
+
}
|
|
426
|
+
return url;
|
|
618
427
|
}
|
|
619
428
|
function _stripIndexHtml(url) {
|
|
620
|
-
|
|
429
|
+
return url.replace(/\/index.html$/, '');
|
|
621
430
|
}
|
|
622
431
|
function _stripOrigin(baseHref) {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
if (isAbsoluteUrl) {
|
|
630
|
-
const [, pathname] = baseHref.split(/\/\/[^\/]+/);
|
|
631
|
-
return pathname;
|
|
632
|
-
}
|
|
633
|
-
return baseHref;
|
|
432
|
+
const isAbsoluteUrl = new RegExp('^(https?:)?//').test(baseHref);
|
|
433
|
+
if (isAbsoluteUrl) {
|
|
434
|
+
const [, pathname] = baseHref.split(/\/\/[^\/]+/);
|
|
435
|
+
return pathname;
|
|
436
|
+
}
|
|
437
|
+
return baseHref;
|
|
634
438
|
}
|
|
635
439
|
|
|
636
440
|
export { APP_BASE_HREF, BrowserPlatformLocation, DomAdapter, LOCATION_INITIALIZED, Location, LocationStrategy, PathLocationStrategy, PlatformLocation, getDOM, joinWithSlash, normalizeQueryParams, setRootDomAdapter };
|