@angular/common 16.0.0-next.4 → 16.0.0-next.5
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/{esm2020 → esm2022}/http/src/client.mjs +4 -4
- package/{esm2020 → esm2022}/http/src/interceptor.mjs +4 -4
- package/{esm2020 → esm2022}/http/src/jsonp.mjs +7 -7
- package/esm2022/http/src/module.mjs +133 -0
- package/esm2022/http/src/xhr.mjs +317 -0
- package/{esm2020 → esm2022}/http/src/xsrf.mjs +7 -7
- package/{esm2020 → esm2022}/http/testing/src/backend.mjs +4 -4
- package/{esm2020 → esm2022}/http/testing/src/module.mjs +7 -7
- package/{esm2020 → esm2022}/src/common_module.mjs +5 -5
- package/{esm2020 → esm2022}/src/directives/ng_class.mjs +4 -4
- package/{esm2020 → esm2022}/src/directives/ng_component_outlet.mjs +4 -4
- package/esm2022/src/directives/ng_for_of.mjs +292 -0
- package/{esm2020 → esm2022}/src/directives/ng_if.mjs +4 -4
- package/esm2022/src/directives/ng_optimized_image/image_loaders/imagekit_loader.mjs +49 -0
- package/{esm2020 → esm2022}/src/directives/ng_optimized_image/lcp_image_observer.mjs +4 -4
- package/{esm2020 → esm2022}/src/directives/ng_optimized_image/ng_optimized_image.mjs +4 -4
- package/{esm2020 → esm2022}/src/directives/ng_optimized_image/preconnect_link_checker.mjs +4 -4
- package/{esm2020 → esm2022}/src/directives/ng_optimized_image/preload-link-creator.mjs +4 -4
- package/{esm2020 → esm2022}/src/directives/ng_plural.mjs +7 -7
- package/{esm2020 → esm2022}/src/directives/ng_style.mjs +4 -4
- package/{esm2020 → esm2022}/src/directives/ng_switch.mjs +10 -10
- package/esm2022/src/directives/ng_template_outlet.mjs +89 -0
- package/{esm2020 → esm2022}/src/i18n/localization.mjs +7 -7
- package/{esm2020 → esm2022}/src/location/hash_location_strategy.mjs +4 -4
- package/{esm2020 → esm2022}/src/location/location.mjs +32 -32
- package/{esm2020 → esm2022}/src/location/location_strategy.mjs +7 -7
- package/{esm2020 → esm2022}/src/location/platform_location.mjs +7 -7
- package/{esm2020 → esm2022}/src/pipes/async_pipe.mjs +4 -4
- package/{esm2020 → esm2022}/src/pipes/case_conversion_pipes.mjs +10 -10
- package/{esm2020 → esm2022}/src/pipes/date_pipe.mjs +4 -4
- package/{esm2020 → esm2022}/src/pipes/i18n_plural_pipe.mjs +4 -4
- package/{esm2020 → esm2022}/src/pipes/i18n_select_pipe.mjs +4 -4
- package/{esm2020 → esm2022}/src/pipes/json_pipe.mjs +4 -4
- package/{esm2020 → esm2022}/src/pipes/keyvalue_pipe.mjs +4 -4
- package/{esm2020 → esm2022}/src/pipes/number_pipe.mjs +10 -10
- package/{esm2020 → esm2022}/src/pipes/slice_pipe.mjs +4 -4
- package/{esm2020 → esm2022}/src/version.mjs +1 -1
- package/esm2022/src/viewport_scroller.mjs +212 -0
- package/{esm2020 → esm2022}/testing/src/location_mock.mjs +4 -4
- package/esm2022/testing/src/mock_location_strategy.mjs +93 -0
- package/{esm2020 → esm2022}/testing/src/mock_platform_location.mjs +4 -4
- package/{esm2020 → esm2022}/upgrade/src/location_upgrade_module.mjs +5 -5
- package/{fesm2020 → fesm2022}/common.mjs +165 -160
- package/fesm2022/common.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/http/testing.mjs +10 -10
- package/{fesm2020 → fesm2022}/http/testing.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/http.mjs +78 -47
- package/{fesm2015 → fesm2022}/http.mjs.map +1 -1
- package/{fesm2020 → fesm2022}/testing.mjs +10 -10
- package/fesm2022/testing.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/upgrade.mjs +5 -5
- package/{fesm2020 → fesm2022}/upgrade.mjs.map +1 -1
- package/http/index.d.ts +5 -2
- package/http/testing/index.d.ts +1 -1
- package/index.d.ts +6 -6
- package/package.json +18 -32
- package/testing/index.d.ts +1 -1
- package/upgrade/index.d.ts +1 -1
- package/esm2020/http/src/module.mjs +0 -133
- package/esm2020/http/src/xhr.mjs +0 -286
- package/esm2020/src/directives/ng_for_of.mjs +0 -293
- package/esm2020/src/directives/ng_optimized_image/image_loaders/imagekit_loader.mjs +0 -44
- package/esm2020/src/directives/ng_template_outlet.mjs +0 -88
- package/esm2020/src/viewport_scroller.mjs +0 -212
- package/esm2020/testing/src/mock_location_strategy.mjs +0 -93
- package/fesm2015/common.mjs +0 -6706
- package/fesm2015/common.mjs.map +0 -1
- package/fesm2015/http/testing.mjs +0 -362
- package/fesm2015/http/testing.mjs.map +0 -1
- package/fesm2015/http.mjs +0 -2383
- package/fesm2015/testing.mjs +0 -535
- package/fesm2015/testing.mjs.map +0 -1
- package/fesm2015/upgrade.mjs +0 -894
- package/fesm2015/upgrade.mjs.map +0 -1
- package/fesm2020/common.mjs.map +0 -1
- package/fesm2020/http.mjs.map +0 -1
- package/fesm2020/testing.mjs.map +0 -1
- /package/{esm2020 → esm2022}/common.mjs +0 -0
- /package/{esm2020 → esm2022}/http/http.mjs +0 -0
- /package/{esm2020 → esm2022}/http/index.mjs +0 -0
- /package/{esm2020 → esm2022}/http/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/http/src/backend.mjs +0 -0
- /package/{esm2020 → esm2022}/http/src/context.mjs +0 -0
- /package/{esm2020 → esm2022}/http/src/headers.mjs +0 -0
- /package/{esm2020 → esm2022}/http/src/params.mjs +0 -0
- /package/{esm2020 → esm2022}/http/src/provider.mjs +0 -0
- /package/{esm2020 → esm2022}/http/src/request.mjs +0 -0
- /package/{esm2020 → esm2022}/http/src/response.mjs +0 -0
- /package/{esm2020 → esm2022}/http/testing/index.mjs +0 -0
- /package/{esm2020 → esm2022}/http/testing/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/http/testing/src/api.mjs +0 -0
- /package/{esm2020 → esm2022}/http/testing/src/provider.mjs +0 -0
- /package/{esm2020 → esm2022}/http/testing/src/request.mjs +0 -0
- /package/{esm2020 → esm2022}/http/testing/testing.mjs +0 -0
- /package/{esm2020 → esm2022}/index.mjs +0 -0
- /package/{esm2020 → esm2022}/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/src/common.mjs +0 -0
- /package/{esm2020 → esm2022}/src/cookie.mjs +0 -0
- /package/{esm2020 → esm2022}/src/directives/index.mjs +0 -0
- /package/{esm2020 → esm2022}/src/directives/ng_optimized_image/asserts.mjs +0 -0
- /package/{esm2020 → esm2022}/src/directives/ng_optimized_image/error_helper.mjs +0 -0
- /package/{esm2020 → esm2022}/src/directives/ng_optimized_image/image_loaders/cloudflare_loader.mjs +0 -0
- /package/{esm2020 → esm2022}/src/directives/ng_optimized_image/image_loaders/cloudinary_loader.mjs +0 -0
- /package/{esm2020 → esm2022}/src/directives/ng_optimized_image/image_loaders/image_loader.mjs +0 -0
- /package/{esm2020 → esm2022}/src/directives/ng_optimized_image/image_loaders/imgix_loader.mjs +0 -0
- /package/{esm2020 → esm2022}/src/directives/ng_optimized_image/index.mjs +0 -0
- /package/{esm2020 → esm2022}/src/directives/ng_optimized_image/tokens.mjs +0 -0
- /package/{esm2020 → esm2022}/src/directives/ng_optimized_image/url.mjs +0 -0
- /package/{esm2020 → esm2022}/src/dom_adapter.mjs +0 -0
- /package/{esm2020 → esm2022}/src/dom_tokens.mjs +0 -0
- /package/{esm2020 → esm2022}/src/errors.mjs +0 -0
- /package/{esm2020 → esm2022}/src/i18n/currencies.mjs +0 -0
- /package/{esm2020 → esm2022}/src/i18n/format_date.mjs +0 -0
- /package/{esm2020 → esm2022}/src/i18n/format_number.mjs +0 -0
- /package/{esm2020 → esm2022}/src/i18n/locale_data.mjs +0 -0
- /package/{esm2020 → esm2022}/src/i18n/locale_data_api.mjs +0 -0
- /package/{esm2020 → esm2022}/src/location/index.mjs +0 -0
- /package/{esm2020 → esm2022}/src/location/util.mjs +0 -0
- /package/{esm2020 → esm2022}/src/pipes/date_pipe_config.mjs +0 -0
- /package/{esm2020 → esm2022}/src/pipes/index.mjs +0 -0
- /package/{esm2020 → esm2022}/src/pipes/invalid_pipe_argument_error.mjs +0 -0
- /package/{esm2020 → esm2022}/src/platform_id.mjs +0 -0
- /package/{esm2020 → esm2022}/src/private_export.mjs +0 -0
- /package/{esm2020 → esm2022}/src/xhr.mjs +0 -0
- /package/{esm2020 → esm2022}/testing/index.mjs +0 -0
- /package/{esm2020 → esm2022}/testing/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/testing/src/provide_location_mocks.mjs +0 -0
- /package/{esm2020 → esm2022}/testing/src/testing.mjs +0 -0
- /package/{esm2020 → esm2022}/testing/testing.mjs +0 -0
- /package/{esm2020 → esm2022}/upgrade/index.mjs +0 -0
- /package/{esm2020 → esm2022}/upgrade/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/upgrade/src/index.mjs +0 -0
- /package/{esm2020 → esm2022}/upgrade/src/location_shim.mjs +0 -0
- /package/{esm2020 → esm2022}/upgrade/src/params.mjs +0 -0
- /package/{esm2020 → esm2022}/upgrade/src/utils.mjs +0 -0
- /package/{esm2020 → esm2022}/upgrade/upgrade.mjs +0 -0
package/fesm2015/upgrade.mjs
DELETED
|
@@ -1,894 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Angular v16.0.0-next.4
|
|
3
|
-
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
|
-
* License: MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import * as i0 from '@angular/core';
|
|
8
|
-
import { ɵisPromise, InjectionToken, Inject, Optional, NgModule } from '@angular/core';
|
|
9
|
-
import { ReplaySubject } from 'rxjs';
|
|
10
|
-
import { Location, PlatformLocation, LocationStrategy, APP_BASE_HREF, CommonModule, HashLocationStrategy, PathLocationStrategy } from '@angular/common';
|
|
11
|
-
import { UpgradeModule } from '@angular/upgrade/static';
|
|
12
|
-
|
|
13
|
-
function stripPrefix(val, prefix) {
|
|
14
|
-
return val.startsWith(prefix) ? val.substring(prefix.length) : val;
|
|
15
|
-
}
|
|
16
|
-
function deepEqual(a, b) {
|
|
17
|
-
if (a === b) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
else if (!a || !b) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
try {
|
|
25
|
-
if ((a.prototype !== b.prototype) || (Array.isArray(a) && Array.isArray(b))) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
return JSON.stringify(a) === JSON.stringify(b);
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function isAnchor(el) {
|
|
36
|
-
return el.href !== undefined;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const PATH_MATCH = /^([^?#]*)(\?([^#]*))?(#(.*))?$/;
|
|
40
|
-
const DOUBLE_SLASH_REGEX = /^\s*[\\/]{2,}/;
|
|
41
|
-
const IGNORE_URI_REGEXP = /^\s*(javascript|mailto):/i;
|
|
42
|
-
const DEFAULT_PORTS = {
|
|
43
|
-
'http:': 80,
|
|
44
|
-
'https:': 443,
|
|
45
|
-
'ftp:': 21
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Location service that provides a drop-in replacement for the $location service
|
|
49
|
-
* provided in AngularJS.
|
|
50
|
-
*
|
|
51
|
-
* @see [Using the Angular Unified Location Service](guide/upgrade#using-the-unified-angular-location-service)
|
|
52
|
-
*
|
|
53
|
-
* @publicApi
|
|
54
|
-
*/
|
|
55
|
-
class $locationShim {
|
|
56
|
-
constructor($injector, location, platformLocation, urlCodec, locationStrategy) {
|
|
57
|
-
this.location = location;
|
|
58
|
-
this.platformLocation = platformLocation;
|
|
59
|
-
this.urlCodec = urlCodec;
|
|
60
|
-
this.locationStrategy = locationStrategy;
|
|
61
|
-
this.initializing = true;
|
|
62
|
-
this.updateBrowser = false;
|
|
63
|
-
this.$$absUrl = '';
|
|
64
|
-
this.$$url = '';
|
|
65
|
-
this.$$host = '';
|
|
66
|
-
this.$$replace = false;
|
|
67
|
-
this.$$path = '';
|
|
68
|
-
this.$$search = '';
|
|
69
|
-
this.$$hash = '';
|
|
70
|
-
this.$$changeListeners = [];
|
|
71
|
-
this.cachedState = null;
|
|
72
|
-
this.urlChanges = new ReplaySubject(1);
|
|
73
|
-
this.lastBrowserUrl = '';
|
|
74
|
-
// This variable should be used *only* inside the cacheState function.
|
|
75
|
-
this.lastCachedState = null;
|
|
76
|
-
const initialUrl = this.browserUrl();
|
|
77
|
-
let parsedUrl = this.urlCodec.parse(initialUrl);
|
|
78
|
-
if (typeof parsedUrl === 'string') {
|
|
79
|
-
throw 'Invalid URL';
|
|
80
|
-
}
|
|
81
|
-
this.$$protocol = parsedUrl.protocol;
|
|
82
|
-
this.$$host = parsedUrl.hostname;
|
|
83
|
-
this.$$port = parseInt(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null;
|
|
84
|
-
this.$$parseLinkUrl(initialUrl, initialUrl);
|
|
85
|
-
this.cacheState();
|
|
86
|
-
this.$$state = this.browserState();
|
|
87
|
-
this.location.onUrlChange((newUrl, newState) => {
|
|
88
|
-
this.urlChanges.next({ newUrl, newState });
|
|
89
|
-
});
|
|
90
|
-
if (ɵisPromise($injector)) {
|
|
91
|
-
$injector.then($i => this.initialize($i));
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
this.initialize($injector);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
initialize($injector) {
|
|
98
|
-
const $rootScope = $injector.get('$rootScope');
|
|
99
|
-
const $rootElement = $injector.get('$rootElement');
|
|
100
|
-
$rootElement.on('click', (event) => {
|
|
101
|
-
if (event.ctrlKey || event.metaKey || event.shiftKey || event.which === 2 ||
|
|
102
|
-
event.button === 2) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
let elm = event.target;
|
|
106
|
-
// traverse the DOM up to find first A tag
|
|
107
|
-
while (elm && elm.nodeName.toLowerCase() !== 'a') {
|
|
108
|
-
// ignore rewriting if no A tag (reached root element, or no parent - removed from document)
|
|
109
|
-
if (elm === $rootElement[0] || !(elm = elm.parentNode)) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (!isAnchor(elm)) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
const absHref = elm.href;
|
|
117
|
-
const relHref = elm.getAttribute('href');
|
|
118
|
-
// Ignore when url is started with javascript: or mailto:
|
|
119
|
-
if (IGNORE_URI_REGEXP.test(absHref)) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (absHref && !elm.getAttribute('target') && !event.isDefaultPrevented()) {
|
|
123
|
-
if (this.$$parseLinkUrl(absHref, relHref)) {
|
|
124
|
-
// We do a preventDefault for all urls that are part of the AngularJS application,
|
|
125
|
-
// in html5mode and also without, so that we are able to abort navigation without
|
|
126
|
-
// getting double entries in the location history.
|
|
127
|
-
event.preventDefault();
|
|
128
|
-
// update location manually
|
|
129
|
-
if (this.absUrl() !== this.browserUrl()) {
|
|
130
|
-
$rootScope.$apply();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
this.urlChanges.subscribe(({ newUrl, newState }) => {
|
|
136
|
-
const oldUrl = this.absUrl();
|
|
137
|
-
const oldState = this.$$state;
|
|
138
|
-
this.$$parse(newUrl);
|
|
139
|
-
newUrl = this.absUrl();
|
|
140
|
-
this.$$state = newState;
|
|
141
|
-
const defaultPrevented = $rootScope.$broadcast('$locationChangeStart', newUrl, oldUrl, newState, oldState)
|
|
142
|
-
.defaultPrevented;
|
|
143
|
-
// if the location was changed by a `$locationChangeStart` handler then stop
|
|
144
|
-
// processing this location change
|
|
145
|
-
if (this.absUrl() !== newUrl)
|
|
146
|
-
return;
|
|
147
|
-
// If default was prevented, set back to old state. This is the state that was locally
|
|
148
|
-
// cached in the $location service.
|
|
149
|
-
if (defaultPrevented) {
|
|
150
|
-
this.$$parse(oldUrl);
|
|
151
|
-
this.state(oldState);
|
|
152
|
-
this.setBrowserUrlWithFallback(oldUrl, false, oldState);
|
|
153
|
-
this.$$notifyChangeListeners(this.url(), this.$$state, oldUrl, oldState);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
this.initializing = false;
|
|
157
|
-
$rootScope.$broadcast('$locationChangeSuccess', newUrl, oldUrl, newState, oldState);
|
|
158
|
-
this.resetBrowserUpdate();
|
|
159
|
-
}
|
|
160
|
-
if (!$rootScope.$$phase) {
|
|
161
|
-
$rootScope.$digest();
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
// update browser
|
|
165
|
-
$rootScope.$watch(() => {
|
|
166
|
-
if (this.initializing || this.updateBrowser) {
|
|
167
|
-
this.updateBrowser = false;
|
|
168
|
-
const oldUrl = this.browserUrl();
|
|
169
|
-
const newUrl = this.absUrl();
|
|
170
|
-
const oldState = this.browserState();
|
|
171
|
-
let currentReplace = this.$$replace;
|
|
172
|
-
const urlOrStateChanged = !this.urlCodec.areEqual(oldUrl, newUrl) || oldState !== this.$$state;
|
|
173
|
-
// Fire location changes one time to on initialization. This must be done on the
|
|
174
|
-
// next tick (thus inside $evalAsync()) in order for listeners to be registered
|
|
175
|
-
// before the event fires. Mimicing behavior from $locationWatch:
|
|
176
|
-
// https://github.com/angular/angular.js/blob/master/src/ng/location.js#L983
|
|
177
|
-
if (this.initializing || urlOrStateChanged) {
|
|
178
|
-
this.initializing = false;
|
|
179
|
-
$rootScope.$evalAsync(() => {
|
|
180
|
-
// Get the new URL again since it could have changed due to async update
|
|
181
|
-
const newUrl = this.absUrl();
|
|
182
|
-
const defaultPrevented = $rootScope
|
|
183
|
-
.$broadcast('$locationChangeStart', newUrl, oldUrl, this.$$state, oldState)
|
|
184
|
-
.defaultPrevented;
|
|
185
|
-
// if the location was changed by a `$locationChangeStart` handler then stop
|
|
186
|
-
// processing this location change
|
|
187
|
-
if (this.absUrl() !== newUrl)
|
|
188
|
-
return;
|
|
189
|
-
if (defaultPrevented) {
|
|
190
|
-
this.$$parse(oldUrl);
|
|
191
|
-
this.$$state = oldState;
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
// This block doesn't run when initializing because it's going to perform the update
|
|
195
|
-
// to the URL which shouldn't be needed when initializing.
|
|
196
|
-
if (urlOrStateChanged) {
|
|
197
|
-
this.setBrowserUrlWithFallback(newUrl, currentReplace, oldState === this.$$state ? null : this.$$state);
|
|
198
|
-
this.$$replace = false;
|
|
199
|
-
}
|
|
200
|
-
$rootScope.$broadcast('$locationChangeSuccess', newUrl, oldUrl, this.$$state, oldState);
|
|
201
|
-
if (urlOrStateChanged) {
|
|
202
|
-
this.$$notifyChangeListeners(this.url(), this.$$state, oldUrl, oldState);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
this.$$replace = false;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
resetBrowserUpdate() {
|
|
212
|
-
this.$$replace = false;
|
|
213
|
-
this.$$state = this.browserState();
|
|
214
|
-
this.updateBrowser = false;
|
|
215
|
-
this.lastBrowserUrl = this.browserUrl();
|
|
216
|
-
}
|
|
217
|
-
browserUrl(url, replace, state) {
|
|
218
|
-
// In modern browsers `history.state` is `null` by default; treating it separately
|
|
219
|
-
// from `undefined` would cause `$browser.url('/foo')` to change `history.state`
|
|
220
|
-
// to undefined via `pushState`. Instead, let's change `undefined` to `null` here.
|
|
221
|
-
if (typeof state === 'undefined') {
|
|
222
|
-
state = null;
|
|
223
|
-
}
|
|
224
|
-
// setter
|
|
225
|
-
if (url) {
|
|
226
|
-
let sameState = this.lastHistoryState === state;
|
|
227
|
-
// Normalize the inputted URL
|
|
228
|
-
url = this.urlCodec.parse(url).href;
|
|
229
|
-
// Don't change anything if previous and current URLs and states match.
|
|
230
|
-
if (this.lastBrowserUrl === url && sameState) {
|
|
231
|
-
return this;
|
|
232
|
-
}
|
|
233
|
-
this.lastBrowserUrl = url;
|
|
234
|
-
this.lastHistoryState = state;
|
|
235
|
-
// Remove server base from URL as the Angular APIs for updating URL require
|
|
236
|
-
// it to be the path+.
|
|
237
|
-
url = this.stripBaseUrl(this.getServerBase(), url) || url;
|
|
238
|
-
// Set the URL
|
|
239
|
-
if (replace) {
|
|
240
|
-
this.locationStrategy.replaceState(state, '', url, '');
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
this.locationStrategy.pushState(state, '', url, '');
|
|
244
|
-
}
|
|
245
|
-
this.cacheState();
|
|
246
|
-
return this;
|
|
247
|
-
// getter
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
return this.platformLocation.href;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
cacheState() {
|
|
254
|
-
// This should be the only place in $browser where `history.state` is read.
|
|
255
|
-
this.cachedState = this.platformLocation.getState();
|
|
256
|
-
if (typeof this.cachedState === 'undefined') {
|
|
257
|
-
this.cachedState = null;
|
|
258
|
-
}
|
|
259
|
-
// Prevent callbacks fo fire twice if both hashchange & popstate were fired.
|
|
260
|
-
if (deepEqual(this.cachedState, this.lastCachedState)) {
|
|
261
|
-
this.cachedState = this.lastCachedState;
|
|
262
|
-
}
|
|
263
|
-
this.lastCachedState = this.cachedState;
|
|
264
|
-
this.lastHistoryState = this.cachedState;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* This function emulates the $browser.state() function from AngularJS. It will cause
|
|
268
|
-
* history.state to be cached unless changed with deep equality check.
|
|
269
|
-
*/
|
|
270
|
-
browserState() {
|
|
271
|
-
return this.cachedState;
|
|
272
|
-
}
|
|
273
|
-
stripBaseUrl(base, url) {
|
|
274
|
-
if (url.startsWith(base)) {
|
|
275
|
-
return url.slice(base.length);
|
|
276
|
-
}
|
|
277
|
-
return undefined;
|
|
278
|
-
}
|
|
279
|
-
getServerBase() {
|
|
280
|
-
const { protocol, hostname, port } = this.platformLocation;
|
|
281
|
-
const baseHref = this.locationStrategy.getBaseHref();
|
|
282
|
-
let url = `${protocol}//${hostname}${port ? ':' + port : ''}${baseHref || '/'}`;
|
|
283
|
-
return url.endsWith('/') ? url : url + '/';
|
|
284
|
-
}
|
|
285
|
-
parseAppUrl(url) {
|
|
286
|
-
if (DOUBLE_SLASH_REGEX.test(url)) {
|
|
287
|
-
throw new Error(`Bad Path - URL cannot start with double slashes: ${url}`);
|
|
288
|
-
}
|
|
289
|
-
let prefixed = (url.charAt(0) !== '/');
|
|
290
|
-
if (prefixed) {
|
|
291
|
-
url = '/' + url;
|
|
292
|
-
}
|
|
293
|
-
let match = this.urlCodec.parse(url, this.getServerBase());
|
|
294
|
-
if (typeof match === 'string') {
|
|
295
|
-
throw new Error(`Bad URL - Cannot parse URL: ${url}`);
|
|
296
|
-
}
|
|
297
|
-
let path = prefixed && match.pathname.charAt(0) === '/' ? match.pathname.substring(1) : match.pathname;
|
|
298
|
-
this.$$path = this.urlCodec.decodePath(path);
|
|
299
|
-
this.$$search = this.urlCodec.decodeSearch(match.search);
|
|
300
|
-
this.$$hash = this.urlCodec.decodeHash(match.hash);
|
|
301
|
-
// make sure path starts with '/';
|
|
302
|
-
if (this.$$path && this.$$path.charAt(0) !== '/') {
|
|
303
|
-
this.$$path = '/' + this.$$path;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Registers listeners for URL changes. This API is used to catch updates performed by the
|
|
308
|
-
* AngularJS framework. These changes are a subset of the `$locationChangeStart` and
|
|
309
|
-
* `$locationChangeSuccess` events which fire when AngularJS updates its internally-referenced
|
|
310
|
-
* version of the browser URL.
|
|
311
|
-
*
|
|
312
|
-
* It's possible for `$locationChange` events to happen, but for the browser URL
|
|
313
|
-
* (window.location) to remain unchanged. This `onChange` callback will fire only when AngularJS
|
|
314
|
-
* actually updates the browser URL (window.location).
|
|
315
|
-
*
|
|
316
|
-
* @param fn The callback function that is triggered for the listener when the URL changes.
|
|
317
|
-
* @param err The callback function that is triggered when an error occurs.
|
|
318
|
-
*/
|
|
319
|
-
onChange(fn, err = (e) => { }) {
|
|
320
|
-
this.$$changeListeners.push([fn, err]);
|
|
321
|
-
}
|
|
322
|
-
/** @internal */
|
|
323
|
-
$$notifyChangeListeners(url = '', state, oldUrl = '', oldState) {
|
|
324
|
-
this.$$changeListeners.forEach(([fn, err]) => {
|
|
325
|
-
try {
|
|
326
|
-
fn(url, state, oldUrl, oldState);
|
|
327
|
-
}
|
|
328
|
-
catch (e) {
|
|
329
|
-
err(e);
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Parses the provided URL, and sets the current URL to the parsed result.
|
|
335
|
-
*
|
|
336
|
-
* @param url The URL string.
|
|
337
|
-
*/
|
|
338
|
-
$$parse(url) {
|
|
339
|
-
let pathUrl;
|
|
340
|
-
if (url.startsWith('/')) {
|
|
341
|
-
pathUrl = url;
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
// Remove protocol & hostname if URL starts with it
|
|
345
|
-
pathUrl = this.stripBaseUrl(this.getServerBase(), url);
|
|
346
|
-
}
|
|
347
|
-
if (typeof pathUrl === 'undefined') {
|
|
348
|
-
throw new Error(`Invalid url "${url}", missing path prefix "${this.getServerBase()}".`);
|
|
349
|
-
}
|
|
350
|
-
this.parseAppUrl(pathUrl);
|
|
351
|
-
if (!this.$$path) {
|
|
352
|
-
this.$$path = '/';
|
|
353
|
-
}
|
|
354
|
-
this.composeUrls();
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Parses the provided URL and its relative URL.
|
|
358
|
-
*
|
|
359
|
-
* @param url The full URL string.
|
|
360
|
-
* @param relHref A URL string relative to the full URL string.
|
|
361
|
-
*/
|
|
362
|
-
$$parseLinkUrl(url, relHref) {
|
|
363
|
-
// When relHref is passed, it should be a hash and is handled separately
|
|
364
|
-
if (relHref && relHref[0] === '#') {
|
|
365
|
-
this.hash(relHref.slice(1));
|
|
366
|
-
return true;
|
|
367
|
-
}
|
|
368
|
-
let rewrittenUrl;
|
|
369
|
-
let appUrl = this.stripBaseUrl(this.getServerBase(), url);
|
|
370
|
-
if (typeof appUrl !== 'undefined') {
|
|
371
|
-
rewrittenUrl = this.getServerBase() + appUrl;
|
|
372
|
-
}
|
|
373
|
-
else if (this.getServerBase() === url + '/') {
|
|
374
|
-
rewrittenUrl = this.getServerBase();
|
|
375
|
-
}
|
|
376
|
-
// Set the URL
|
|
377
|
-
if (rewrittenUrl) {
|
|
378
|
-
this.$$parse(rewrittenUrl);
|
|
379
|
-
}
|
|
380
|
-
return !!rewrittenUrl;
|
|
381
|
-
}
|
|
382
|
-
setBrowserUrlWithFallback(url, replace, state) {
|
|
383
|
-
const oldUrl = this.url();
|
|
384
|
-
const oldState = this.$$state;
|
|
385
|
-
try {
|
|
386
|
-
this.browserUrl(url, replace, state);
|
|
387
|
-
// Make sure $location.state() returns referentially identical (not just deeply equal)
|
|
388
|
-
// state object; this makes possible quick checking if the state changed in the digest
|
|
389
|
-
// loop. Checking deep equality would be too expensive.
|
|
390
|
-
this.$$state = this.browserState();
|
|
391
|
-
}
|
|
392
|
-
catch (e) {
|
|
393
|
-
// Restore old values if pushState fails
|
|
394
|
-
this.url(oldUrl);
|
|
395
|
-
this.$$state = oldState;
|
|
396
|
-
throw e;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
composeUrls() {
|
|
400
|
-
this.$$url = this.urlCodec.normalize(this.$$path, this.$$search, this.$$hash);
|
|
401
|
-
this.$$absUrl = this.getServerBase() + this.$$url.slice(1); // remove '/' from front of URL
|
|
402
|
-
this.updateBrowser = true;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Retrieves the full URL representation with all segments encoded according to
|
|
406
|
-
* rules specified in
|
|
407
|
-
* [RFC 3986](https://tools.ietf.org/html/rfc3986).
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
* ```js
|
|
411
|
-
* // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
|
|
412
|
-
* let absUrl = $location.absUrl();
|
|
413
|
-
* // => "http://example.com/#/some/path?foo=bar&baz=xoxo"
|
|
414
|
-
* ```
|
|
415
|
-
*/
|
|
416
|
-
absUrl() {
|
|
417
|
-
return this.$$absUrl;
|
|
418
|
-
}
|
|
419
|
-
url(url) {
|
|
420
|
-
if (typeof url === 'string') {
|
|
421
|
-
if (!url.length) {
|
|
422
|
-
url = '/';
|
|
423
|
-
}
|
|
424
|
-
const match = PATH_MATCH.exec(url);
|
|
425
|
-
if (!match)
|
|
426
|
-
return this;
|
|
427
|
-
if (match[1] || url === '')
|
|
428
|
-
this.path(this.urlCodec.decodePath(match[1]));
|
|
429
|
-
if (match[2] || match[1] || url === '')
|
|
430
|
-
this.search(match[3] || '');
|
|
431
|
-
this.hash(match[5] || '');
|
|
432
|
-
// Chainable method
|
|
433
|
-
return this;
|
|
434
|
-
}
|
|
435
|
-
return this.$$url;
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Retrieves the protocol of the current URL.
|
|
439
|
-
*
|
|
440
|
-
* ```js
|
|
441
|
-
* // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
|
|
442
|
-
* let protocol = $location.protocol();
|
|
443
|
-
* // => "http"
|
|
444
|
-
* ```
|
|
445
|
-
*/
|
|
446
|
-
protocol() {
|
|
447
|
-
return this.$$protocol;
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Retrieves the protocol of the current URL.
|
|
451
|
-
*
|
|
452
|
-
* In contrast to the non-AngularJS version `location.host` which returns `hostname:port`, this
|
|
453
|
-
* returns the `hostname` portion only.
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
* ```js
|
|
457
|
-
* // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
|
|
458
|
-
* let host = $location.host();
|
|
459
|
-
* // => "example.com"
|
|
460
|
-
*
|
|
461
|
-
* // given URL http://user:password@example.com:8080/#/some/path?foo=bar&baz=xoxo
|
|
462
|
-
* host = $location.host();
|
|
463
|
-
* // => "example.com"
|
|
464
|
-
* host = location.host;
|
|
465
|
-
* // => "example.com:8080"
|
|
466
|
-
* ```
|
|
467
|
-
*/
|
|
468
|
-
host() {
|
|
469
|
-
return this.$$host;
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Retrieves the port of the current URL.
|
|
473
|
-
*
|
|
474
|
-
* ```js
|
|
475
|
-
* // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
|
|
476
|
-
* let port = $location.port();
|
|
477
|
-
* // => 80
|
|
478
|
-
* ```
|
|
479
|
-
*/
|
|
480
|
-
port() {
|
|
481
|
-
return this.$$port;
|
|
482
|
-
}
|
|
483
|
-
path(path) {
|
|
484
|
-
if (typeof path === 'undefined') {
|
|
485
|
-
return this.$$path;
|
|
486
|
-
}
|
|
487
|
-
// null path converts to empty string. Prepend with "/" if needed.
|
|
488
|
-
path = path !== null ? path.toString() : '';
|
|
489
|
-
path = path.charAt(0) === '/' ? path : '/' + path;
|
|
490
|
-
this.$$path = path;
|
|
491
|
-
this.composeUrls();
|
|
492
|
-
return this;
|
|
493
|
-
}
|
|
494
|
-
search(search, paramValue) {
|
|
495
|
-
switch (arguments.length) {
|
|
496
|
-
case 0:
|
|
497
|
-
return this.$$search;
|
|
498
|
-
case 1:
|
|
499
|
-
if (typeof search === 'string' || typeof search === 'number') {
|
|
500
|
-
this.$$search = this.urlCodec.decodeSearch(search.toString());
|
|
501
|
-
}
|
|
502
|
-
else if (typeof search === 'object' && search !== null) {
|
|
503
|
-
// Copy the object so it's never mutated
|
|
504
|
-
search = Object.assign({}, search);
|
|
505
|
-
// remove object undefined or null properties
|
|
506
|
-
for (const key in search) {
|
|
507
|
-
if (search[key] == null)
|
|
508
|
-
delete search[key];
|
|
509
|
-
}
|
|
510
|
-
this.$$search = search;
|
|
511
|
-
}
|
|
512
|
-
else {
|
|
513
|
-
throw new Error('LocationProvider.search(): First argument must be a string or an object.');
|
|
514
|
-
}
|
|
515
|
-
break;
|
|
516
|
-
default:
|
|
517
|
-
if (typeof search === 'string') {
|
|
518
|
-
const currentSearch = this.search();
|
|
519
|
-
if (typeof paramValue === 'undefined' || paramValue === null) {
|
|
520
|
-
delete currentSearch[search];
|
|
521
|
-
return this.search(currentSearch);
|
|
522
|
-
}
|
|
523
|
-
else {
|
|
524
|
-
currentSearch[search] = paramValue;
|
|
525
|
-
return this.search(currentSearch);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
this.composeUrls();
|
|
530
|
-
return this;
|
|
531
|
-
}
|
|
532
|
-
hash(hash) {
|
|
533
|
-
if (typeof hash === 'undefined') {
|
|
534
|
-
return this.$$hash;
|
|
535
|
-
}
|
|
536
|
-
this.$$hash = hash !== null ? hash.toString() : '';
|
|
537
|
-
this.composeUrls();
|
|
538
|
-
return this;
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Changes to `$location` during the current `$digest` will replace the current
|
|
542
|
-
* history record, instead of adding a new one.
|
|
543
|
-
*/
|
|
544
|
-
replace() {
|
|
545
|
-
this.$$replace = true;
|
|
546
|
-
return this;
|
|
547
|
-
}
|
|
548
|
-
state(state) {
|
|
549
|
-
if (typeof state === 'undefined') {
|
|
550
|
-
return this.$$state;
|
|
551
|
-
}
|
|
552
|
-
this.$$state = state;
|
|
553
|
-
return this;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* The factory function used to create an instance of the `$locationShim` in Angular,
|
|
558
|
-
* and provides an API-compatible `$locationProvider` for AngularJS.
|
|
559
|
-
*
|
|
560
|
-
* @publicApi
|
|
561
|
-
*/
|
|
562
|
-
class $locationShimProvider {
|
|
563
|
-
constructor(ngUpgrade, location, platformLocation, urlCodec, locationStrategy) {
|
|
564
|
-
this.ngUpgrade = ngUpgrade;
|
|
565
|
-
this.location = location;
|
|
566
|
-
this.platformLocation = platformLocation;
|
|
567
|
-
this.urlCodec = urlCodec;
|
|
568
|
-
this.locationStrategy = locationStrategy;
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* Factory method that returns an instance of the $locationShim
|
|
572
|
-
*/
|
|
573
|
-
$get() {
|
|
574
|
-
return new $locationShim(this.ngUpgrade.$injector, this.location, this.platformLocation, this.urlCodec, this.locationStrategy);
|
|
575
|
-
}
|
|
576
|
-
/**
|
|
577
|
-
* Stub method used to keep API compatible with AngularJS. This setting is configured through
|
|
578
|
-
* the LocationUpgradeModule's `config` method in your Angular app.
|
|
579
|
-
*/
|
|
580
|
-
hashPrefix(prefix) {
|
|
581
|
-
throw new Error('Configure LocationUpgrade through LocationUpgradeModule.config method.');
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Stub method used to keep API compatible with AngularJS. This setting is configured through
|
|
585
|
-
* the LocationUpgradeModule's `config` method in your Angular app.
|
|
586
|
-
*/
|
|
587
|
-
html5Mode(mode) {
|
|
588
|
-
throw new Error('Configure LocationUpgrade through LocationUpgradeModule.config method.');
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* A codec for encoding and decoding URL parts.
|
|
594
|
-
*
|
|
595
|
-
* @publicApi
|
|
596
|
-
**/
|
|
597
|
-
class UrlCodec {
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* A `UrlCodec` that uses logic from AngularJS to serialize and parse URLs
|
|
601
|
-
* and URL parameters.
|
|
602
|
-
*
|
|
603
|
-
* @publicApi
|
|
604
|
-
*/
|
|
605
|
-
class AngularJSUrlCodec {
|
|
606
|
-
// https://github.com/angular/angular.js/blob/864c7f0/src/ng/location.js#L15
|
|
607
|
-
encodePath(path) {
|
|
608
|
-
const segments = path.split('/');
|
|
609
|
-
let i = segments.length;
|
|
610
|
-
while (i--) {
|
|
611
|
-
// decode forward slashes to prevent them from being double encoded
|
|
612
|
-
segments[i] = encodeUriSegment(segments[i].replace(/%2F/g, '/'));
|
|
613
|
-
}
|
|
614
|
-
path = segments.join('/');
|
|
615
|
-
return _stripIndexHtml((path && path[0] !== '/' && '/' || '') + path);
|
|
616
|
-
}
|
|
617
|
-
// https://github.com/angular/angular.js/blob/864c7f0/src/ng/location.js#L42
|
|
618
|
-
encodeSearch(search) {
|
|
619
|
-
if (typeof search === 'string') {
|
|
620
|
-
search = parseKeyValue(search);
|
|
621
|
-
}
|
|
622
|
-
search = toKeyValue(search);
|
|
623
|
-
return search ? '?' + search : '';
|
|
624
|
-
}
|
|
625
|
-
// https://github.com/angular/angular.js/blob/864c7f0/src/ng/location.js#L44
|
|
626
|
-
encodeHash(hash) {
|
|
627
|
-
hash = encodeUriSegment(hash);
|
|
628
|
-
return hash ? '#' + hash : '';
|
|
629
|
-
}
|
|
630
|
-
// https://github.com/angular/angular.js/blob/864c7f0/src/ng/location.js#L27
|
|
631
|
-
decodePath(path, html5Mode = true) {
|
|
632
|
-
const segments = path.split('/');
|
|
633
|
-
let i = segments.length;
|
|
634
|
-
while (i--) {
|
|
635
|
-
segments[i] = decodeURIComponent(segments[i]);
|
|
636
|
-
if (html5Mode) {
|
|
637
|
-
// encode forward slashes to prevent them from being mistaken for path separators
|
|
638
|
-
segments[i] = segments[i].replace(/\//g, '%2F');
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
return segments.join('/');
|
|
642
|
-
}
|
|
643
|
-
// https://github.com/angular/angular.js/blob/864c7f0/src/ng/location.js#L72
|
|
644
|
-
decodeSearch(search) {
|
|
645
|
-
return parseKeyValue(search);
|
|
646
|
-
}
|
|
647
|
-
// https://github.com/angular/angular.js/blob/864c7f0/src/ng/location.js#L73
|
|
648
|
-
decodeHash(hash) {
|
|
649
|
-
hash = decodeURIComponent(hash);
|
|
650
|
-
return hash[0] === '#' ? hash.substring(1) : hash;
|
|
651
|
-
}
|
|
652
|
-
normalize(pathOrHref, search, hash, baseUrl) {
|
|
653
|
-
if (arguments.length === 1) {
|
|
654
|
-
const parsed = this.parse(pathOrHref, baseUrl);
|
|
655
|
-
if (typeof parsed === 'string') {
|
|
656
|
-
return parsed;
|
|
657
|
-
}
|
|
658
|
-
const serverUrl = `${parsed.protocol}://${parsed.hostname}${parsed.port ? ':' + parsed.port : ''}`;
|
|
659
|
-
return this.normalize(this.decodePath(parsed.pathname), this.decodeSearch(parsed.search), this.decodeHash(parsed.hash), serverUrl);
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
662
|
-
const encPath = this.encodePath(pathOrHref);
|
|
663
|
-
const encSearch = search && this.encodeSearch(search) || '';
|
|
664
|
-
const encHash = hash && this.encodeHash(hash) || '';
|
|
665
|
-
let joinedPath = (baseUrl || '') + encPath;
|
|
666
|
-
if (!joinedPath.length || joinedPath[0] !== '/') {
|
|
667
|
-
joinedPath = '/' + joinedPath;
|
|
668
|
-
}
|
|
669
|
-
return joinedPath + encSearch + encHash;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
areEqual(valA, valB) {
|
|
673
|
-
return this.normalize(valA) === this.normalize(valB);
|
|
674
|
-
}
|
|
675
|
-
// https://github.com/angular/angular.js/blob/864c7f0/src/ng/urlUtils.js#L60
|
|
676
|
-
parse(url, base) {
|
|
677
|
-
try {
|
|
678
|
-
// Safari 12 throws an error when the URL constructor is called with an undefined base.
|
|
679
|
-
const parsed = !base ? new URL(url) : new URL(url, base);
|
|
680
|
-
return {
|
|
681
|
-
href: parsed.href,
|
|
682
|
-
protocol: parsed.protocol ? parsed.protocol.replace(/:$/, '') : '',
|
|
683
|
-
host: parsed.host,
|
|
684
|
-
search: parsed.search ? parsed.search.replace(/^\?/, '') : '',
|
|
685
|
-
hash: parsed.hash ? parsed.hash.replace(/^#/, '') : '',
|
|
686
|
-
hostname: parsed.hostname,
|
|
687
|
-
port: parsed.port,
|
|
688
|
-
pathname: (parsed.pathname.charAt(0) === '/') ? parsed.pathname : '/' + parsed.pathname
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
catch (e) {
|
|
692
|
-
throw new Error(`Invalid URL (${url}) with base (${base})`);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
function _stripIndexHtml(url) {
|
|
697
|
-
return url.replace(/\/index.html$/, '');
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* Tries to decode the URI component without throwing an exception.
|
|
701
|
-
*
|
|
702
|
-
* @param str value potential URI component to check.
|
|
703
|
-
* @returns the decoded URI if it can be decoded or else `undefined`.
|
|
704
|
-
*/
|
|
705
|
-
function tryDecodeURIComponent(value) {
|
|
706
|
-
try {
|
|
707
|
-
return decodeURIComponent(value);
|
|
708
|
-
}
|
|
709
|
-
catch (e) {
|
|
710
|
-
// Ignore any invalid uri component.
|
|
711
|
-
return undefined;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
/**
|
|
715
|
-
* Parses an escaped url query string into key-value pairs. Logic taken from
|
|
716
|
-
* https://github.com/angular/angular.js/blob/864c7f0/src/Angular.js#L1382
|
|
717
|
-
*/
|
|
718
|
-
function parseKeyValue(keyValue) {
|
|
719
|
-
const obj = {};
|
|
720
|
-
(keyValue || '').split('&').forEach((keyValue) => {
|
|
721
|
-
let splitPoint, key, val;
|
|
722
|
-
if (keyValue) {
|
|
723
|
-
key = keyValue = keyValue.replace(/\+/g, '%20');
|
|
724
|
-
splitPoint = keyValue.indexOf('=');
|
|
725
|
-
if (splitPoint !== -1) {
|
|
726
|
-
key = keyValue.substring(0, splitPoint);
|
|
727
|
-
val = keyValue.substring(splitPoint + 1);
|
|
728
|
-
}
|
|
729
|
-
key = tryDecodeURIComponent(key);
|
|
730
|
-
if (typeof key !== 'undefined') {
|
|
731
|
-
val = typeof val !== 'undefined' ? tryDecodeURIComponent(val) : true;
|
|
732
|
-
if (!obj.hasOwnProperty(key)) {
|
|
733
|
-
obj[key] = val;
|
|
734
|
-
}
|
|
735
|
-
else if (Array.isArray(obj[key])) {
|
|
736
|
-
obj[key].push(val);
|
|
737
|
-
}
|
|
738
|
-
else {
|
|
739
|
-
obj[key] = [obj[key], val];
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
});
|
|
744
|
-
return obj;
|
|
745
|
-
}
|
|
746
|
-
/**
|
|
747
|
-
* Serializes into key-value pairs. Logic taken from
|
|
748
|
-
* https://github.com/angular/angular.js/blob/864c7f0/src/Angular.js#L1409
|
|
749
|
-
*/
|
|
750
|
-
function toKeyValue(obj) {
|
|
751
|
-
const parts = [];
|
|
752
|
-
for (const key in obj) {
|
|
753
|
-
let value = obj[key];
|
|
754
|
-
if (Array.isArray(value)) {
|
|
755
|
-
value.forEach((arrayValue) => {
|
|
756
|
-
parts.push(encodeUriQuery(key, true) +
|
|
757
|
-
(arrayValue === true ? '' : '=' + encodeUriQuery(arrayValue, true)));
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
else {
|
|
761
|
-
parts.push(encodeUriQuery(key, true) +
|
|
762
|
-
(value === true ? '' : '=' + encodeUriQuery(value, true)));
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
return parts.length ? parts.join('&') : '';
|
|
766
|
-
}
|
|
767
|
-
/**
|
|
768
|
-
* We need our custom method because encodeURIComponent is too aggressive and doesn't follow
|
|
769
|
-
* https://tools.ietf.org/html/rfc3986 with regards to the character set (pchar) allowed in path
|
|
770
|
-
* segments:
|
|
771
|
-
* segment = *pchar
|
|
772
|
-
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
|
773
|
-
* pct-encoded = "%" HEXDIG HEXDIG
|
|
774
|
-
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
|
775
|
-
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
|
|
776
|
-
* / "*" / "+" / "," / ";" / "="
|
|
777
|
-
*
|
|
778
|
-
* Logic from https://github.com/angular/angular.js/blob/864c7f0/src/Angular.js#L1437
|
|
779
|
-
*/
|
|
780
|
-
function encodeUriSegment(val) {
|
|
781
|
-
return encodeUriQuery(val, true).replace(/%26/g, '&').replace(/%3D/gi, '=').replace(/%2B/gi, '+');
|
|
782
|
-
}
|
|
783
|
-
/**
|
|
784
|
-
* This method is intended for encoding *key* or *value* parts of query component. We need a custom
|
|
785
|
-
* method because encodeURIComponent is too aggressive and encodes stuff that doesn't have to be
|
|
786
|
-
* encoded per https://tools.ietf.org/html/rfc3986:
|
|
787
|
-
* query = *( pchar / "/" / "?" )
|
|
788
|
-
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
|
789
|
-
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
|
|
790
|
-
* pct-encoded = "%" HEXDIG HEXDIG
|
|
791
|
-
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
|
|
792
|
-
* / "*" / "+" / "," / ";" / "="
|
|
793
|
-
*
|
|
794
|
-
* Logic from https://github.com/angular/angular.js/blob/864c7f0/src/Angular.js#L1456
|
|
795
|
-
*/
|
|
796
|
-
function encodeUriQuery(val, pctEncodeSpaces = false) {
|
|
797
|
-
return encodeURIComponent(val)
|
|
798
|
-
.replace(/%40/g, '@')
|
|
799
|
-
.replace(/%3A/gi, ':')
|
|
800
|
-
.replace(/%24/g, '$')
|
|
801
|
-
.replace(/%2C/gi, ',')
|
|
802
|
-
.replace(/%3B/gi, ';')
|
|
803
|
-
.replace(/%20/g, (pctEncodeSpaces ? '%20' : '+'));
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
/**
|
|
807
|
-
* A provider token used to configure the location upgrade module.
|
|
808
|
-
*
|
|
809
|
-
* @publicApi
|
|
810
|
-
*/
|
|
811
|
-
const LOCATION_UPGRADE_CONFIGURATION = new InjectionToken('LOCATION_UPGRADE_CONFIGURATION');
|
|
812
|
-
const APP_BASE_HREF_RESOLVED = new InjectionToken('APP_BASE_HREF_RESOLVED');
|
|
813
|
-
/**
|
|
814
|
-
* `NgModule` used for providing and configuring Angular's Unified Location Service for upgrading.
|
|
815
|
-
*
|
|
816
|
-
* @see [Using the Unified Angular Location Service](guide/upgrade#using-the-unified-angular-location-service)
|
|
817
|
-
*
|
|
818
|
-
* @publicApi
|
|
819
|
-
*/
|
|
820
|
-
class LocationUpgradeModule {
|
|
821
|
-
static config(config) {
|
|
822
|
-
return {
|
|
823
|
-
ngModule: LocationUpgradeModule,
|
|
824
|
-
providers: [
|
|
825
|
-
Location,
|
|
826
|
-
{
|
|
827
|
-
provide: $locationShim,
|
|
828
|
-
useFactory: provide$location,
|
|
829
|
-
deps: [UpgradeModule, Location, PlatformLocation, UrlCodec, LocationStrategy]
|
|
830
|
-
},
|
|
831
|
-
{ provide: LOCATION_UPGRADE_CONFIGURATION, useValue: config ? config : {} },
|
|
832
|
-
{ provide: UrlCodec, useFactory: provideUrlCodec, deps: [LOCATION_UPGRADE_CONFIGURATION] },
|
|
833
|
-
{
|
|
834
|
-
provide: APP_BASE_HREF_RESOLVED,
|
|
835
|
-
useFactory: provideAppBaseHref,
|
|
836
|
-
deps: [LOCATION_UPGRADE_CONFIGURATION, [new Inject(APP_BASE_HREF), new Optional()]]
|
|
837
|
-
},
|
|
838
|
-
{
|
|
839
|
-
provide: LocationStrategy,
|
|
840
|
-
useFactory: provideLocationStrategy,
|
|
841
|
-
deps: [
|
|
842
|
-
PlatformLocation,
|
|
843
|
-
APP_BASE_HREF_RESOLVED,
|
|
844
|
-
LOCATION_UPGRADE_CONFIGURATION,
|
|
845
|
-
]
|
|
846
|
-
},
|
|
847
|
-
],
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
LocationUpgradeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.4", ngImport: i0, type: LocationUpgradeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
852
|
-
LocationUpgradeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.4", ngImport: i0, type: LocationUpgradeModule, imports: [CommonModule] });
|
|
853
|
-
LocationUpgradeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.4", ngImport: i0, type: LocationUpgradeModule, imports: [CommonModule] });
|
|
854
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.4", ngImport: i0, type: LocationUpgradeModule, decorators: [{
|
|
855
|
-
type: NgModule,
|
|
856
|
-
args: [{ imports: [CommonModule] }]
|
|
857
|
-
}] });
|
|
858
|
-
function provideAppBaseHref(config, appBaseHref) {
|
|
859
|
-
if (config && config.appBaseHref != null) {
|
|
860
|
-
return config.appBaseHref;
|
|
861
|
-
}
|
|
862
|
-
else if (appBaseHref != null) {
|
|
863
|
-
return appBaseHref;
|
|
864
|
-
}
|
|
865
|
-
return '';
|
|
866
|
-
}
|
|
867
|
-
function provideUrlCodec(config) {
|
|
868
|
-
const codec = config && config.urlCodec || AngularJSUrlCodec;
|
|
869
|
-
return new codec();
|
|
870
|
-
}
|
|
871
|
-
function provideLocationStrategy(platformLocation, baseHref, options = {}) {
|
|
872
|
-
return options.useHash ? new HashLocationStrategy(platformLocation, baseHref) :
|
|
873
|
-
new PathLocationStrategy(platformLocation, baseHref);
|
|
874
|
-
}
|
|
875
|
-
function provide$location(ngUpgrade, location, platformLocation, urlCodec, locationStrategy) {
|
|
876
|
-
const $locationProvider = new $locationShimProvider(ngUpgrade, location, platformLocation, urlCodec, locationStrategy);
|
|
877
|
-
return $locationProvider.$get();
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
/**
|
|
881
|
-
* @module
|
|
882
|
-
* @description
|
|
883
|
-
* Entry point for all public APIs of this package.
|
|
884
|
-
*/
|
|
885
|
-
// This file only reexports content of the `src` folder. Keep it that way.
|
|
886
|
-
|
|
887
|
-
// This file is not used to build this module. It is only used during editing
|
|
888
|
-
|
|
889
|
-
/**
|
|
890
|
-
* Generated bundle index. Do not edit.
|
|
891
|
-
*/
|
|
892
|
-
|
|
893
|
-
export { $locationShim, $locationShimProvider, AngularJSUrlCodec, LOCATION_UPGRADE_CONFIGURATION, LocationUpgradeModule, UrlCodec };
|
|
894
|
-
//# sourceMappingURL=upgrade.mjs.map
|