source: trip-planner-front/node_modules/@angular/common/esm2015/http/src/params.js@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 31.3 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/**
9 * Provides encoding and decoding of URL parameter and query-string values.
10 *
11 * Serializes and parses URL parameter keys and values to encode and decode them.
12 * If you pass URL query parameters without encoding,
13 * the query parameters can be misinterpreted at the receiving end.
14 *
15 *
16 * @publicApi
17 */
18export class HttpUrlEncodingCodec {
19 /**
20 * Encodes a key name for a URL parameter or query-string.
21 * @param key The key name.
22 * @returns The encoded key name.
23 */
24 encodeKey(key) {
25 return standardEncoding(key);
26 }
27 /**
28 * Encodes the value of a URL parameter or query-string.
29 * @param value The value.
30 * @returns The encoded value.
31 */
32 encodeValue(value) {
33 return standardEncoding(value);
34 }
35 /**
36 * Decodes an encoded URL parameter or query-string key.
37 * @param key The encoded key name.
38 * @returns The decoded key name.
39 */
40 decodeKey(key) {
41 return decodeURIComponent(key);
42 }
43 /**
44 * Decodes an encoded URL parameter or query-string value.
45 * @param value The encoded value.
46 * @returns The decoded value.
47 */
48 decodeValue(value) {
49 return decodeURIComponent(value);
50 }
51}
52function paramParser(rawParams, codec) {
53 const map = new Map();
54 if (rawParams.length > 0) {
55 // The `window.location.search` can be used while creating an instance of the `HttpParams` class
56 // (e.g. `new HttpParams({ fromString: window.location.search })`). The `window.location.search`
57 // may start with the `?` char, so we strip it if it's present.
58 const params = rawParams.replace(/^\?/, '').split('&');
59 params.forEach((param) => {
60 const eqIdx = param.indexOf('=');
61 const [key, val] = eqIdx == -1 ?
62 [codec.decodeKey(param), ''] :
63 [codec.decodeKey(param.slice(0, eqIdx)), codec.decodeValue(param.slice(eqIdx + 1))];
64 const list = map.get(key) || [];
65 list.push(val);
66 map.set(key, list);
67 });
68 }
69 return map;
70}
71/**
72 * Encode input string with standard encodeURIComponent and then un-encode specific characters.
73 */
74const STANDARD_ENCODING_REGEX = /%(\d[a-f0-9])/gi;
75const STANDARD_ENCODING_REPLACEMENTS = {
76 '40': '@',
77 '3A': ':',
78 '24': '$',
79 '2C': ',',
80 '3B': ';',
81 '2B': '+',
82 '3D': '=',
83 '3F': '?',
84 '2F': '/',
85};
86function standardEncoding(v) {
87 return encodeURIComponent(v).replace(STANDARD_ENCODING_REGEX, (s, t) => { var _a; return (_a = STANDARD_ENCODING_REPLACEMENTS[t]) !== null && _a !== void 0 ? _a : s; });
88}
89function valueToString(value) {
90 return `${value}`;
91}
92/**
93 * An HTTP request/response body that represents serialized parameters,
94 * per the MIME type `application/x-www-form-urlencoded`.
95 *
96 * This class is immutable; all mutation operations return a new instance.
97 *
98 * @publicApi
99 */
100export class HttpParams {
101 constructor(options = {}) {
102 this.updates = null;
103 this.cloneFrom = null;
104 this.encoder = options.encoder || new HttpUrlEncodingCodec();
105 if (!!options.fromString) {
106 if (!!options.fromObject) {
107 throw new Error(`Cannot specify both fromString and fromObject.`);
108 }
109 this.map = paramParser(options.fromString, this.encoder);
110 }
111 else if (!!options.fromObject) {
112 this.map = new Map();
113 Object.keys(options.fromObject).forEach(key => {
114 const value = options.fromObject[key];
115 this.map.set(key, Array.isArray(value) ? value : [value]);
116 });
117 }
118 else {
119 this.map = null;
120 }
121 }
122 /**
123 * Reports whether the body includes one or more values for a given parameter.
124 * @param param The parameter name.
125 * @returns True if the parameter has one or more values,
126 * false if it has no value or is not present.
127 */
128 has(param) {
129 this.init();
130 return this.map.has(param);
131 }
132 /**
133 * Retrieves the first value for a parameter.
134 * @param param The parameter name.
135 * @returns The first value of the given parameter,
136 * or `null` if the parameter is not present.
137 */
138 get(param) {
139 this.init();
140 const res = this.map.get(param);
141 return !!res ? res[0] : null;
142 }
143 /**
144 * Retrieves all values for a parameter.
145 * @param param The parameter name.
146 * @returns All values in a string array,
147 * or `null` if the parameter not present.
148 */
149 getAll(param) {
150 this.init();
151 return this.map.get(param) || null;
152 }
153 /**
154 * Retrieves all the parameters for this body.
155 * @returns The parameter names in a string array.
156 */
157 keys() {
158 this.init();
159 return Array.from(this.map.keys());
160 }
161 /**
162 * Appends a new value to existing values for a parameter.
163 * @param param The parameter name.
164 * @param value The new value to add.
165 * @return A new body with the appended value.
166 */
167 append(param, value) {
168 return this.clone({ param, value, op: 'a' });
169 }
170 /**
171 * Constructs a new body with appended values for the given parameter name.
172 * @param params parameters and values
173 * @return A new body with the new value.
174 */
175 appendAll(params) {
176 const updates = [];
177 Object.keys(params).forEach(param => {
178 const value = params[param];
179 if (Array.isArray(value)) {
180 value.forEach(_value => {
181 updates.push({ param, value: _value, op: 'a' });
182 });
183 }
184 else {
185 updates.push({ param, value: value, op: 'a' });
186 }
187 });
188 return this.clone(updates);
189 }
190 /**
191 * Replaces the value for a parameter.
192 * @param param The parameter name.
193 * @param value The new value.
194 * @return A new body with the new value.
195 */
196 set(param, value) {
197 return this.clone({ param, value, op: 's' });
198 }
199 /**
200 * Removes a given value or all values from a parameter.
201 * @param param The parameter name.
202 * @param value The value to remove, if provided.
203 * @return A new body with the given value removed, or with all values
204 * removed if no value is specified.
205 */
206 delete(param, value) {
207 return this.clone({ param, value, op: 'd' });
208 }
209 /**
210 * Serializes the body to an encoded string, where key-value pairs (separated by `=`) are
211 * separated by `&`s.
212 */
213 toString() {
214 this.init();
215 return this.keys()
216 .map(key => {
217 const eKey = this.encoder.encodeKey(key);
218 // `a: ['1']` produces `'a=1'`
219 // `b: []` produces `''`
220 // `c: ['1', '2']` produces `'c=1&c=2'`
221 return this.map.get(key).map(value => eKey + '=' + this.encoder.encodeValue(value))
222 .join('&');
223 })
224 // filter out empty values because `b: []` produces `''`
225 // which results in `a=1&&c=1&c=2` instead of `a=1&c=1&c=2` if we don't
226 .filter(param => param !== '')
227 .join('&');
228 }
229 clone(update) {
230 const clone = new HttpParams({ encoder: this.encoder });
231 clone.cloneFrom = this.cloneFrom || this;
232 clone.updates = (this.updates || []).concat(update);
233 return clone;
234 }
235 init() {
236 if (this.map === null) {
237 this.map = new Map();
238 }
239 if (this.cloneFrom !== null) {
240 this.cloneFrom.init();
241 this.cloneFrom.keys().forEach(key => this.map.set(key, this.cloneFrom.map.get(key)));
242 this.updates.forEach(update => {
243 switch (update.op) {
244 case 'a':
245 case 's':
246 const base = (update.op === 'a' ? this.map.get(update.param) : undefined) || [];
247 base.push(valueToString(update.value));
248 this.map.set(update.param, base);
249 break;
250 case 'd':
251 if (update.value !== undefined) {
252 let base = this.map.get(update.param) || [];
253 const idx = base.indexOf(valueToString(update.value));
254 if (idx !== -1) {
255 base.splice(idx, 1);
256 }
257 if (base.length > 0) {
258 this.map.set(update.param, base);
259 }
260 else {
261 this.map.delete(update.param);
262 }
263 }
264 else {
265 this.map.delete(update.param);
266 break;
267 }
268 }
269 });
270 this.cloneFrom = this.updates = null;
271 }
272 }
273}
274//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFyYW1zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tbW9uL2h0dHAvc3JjL3BhcmFtcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFpQkg7Ozs7Ozs7OztHQVNHO0FBQ0gsTUFBTSxPQUFPLG9CQUFvQjtJQUMvQjs7OztPQUlHO0lBQ0gsU0FBUyxDQUFDLEdBQVc7UUFDbkIsT0FBTyxnQkFBZ0IsQ0FBQyxHQUFHLENBQUMsQ0FBQztJQUMvQixDQUFDO0lBRUQ7Ozs7T0FJRztJQUNILFdBQVcsQ0FBQyxLQUFhO1FBQ3ZCLE9BQU8sZ0JBQWdCLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDakMsQ0FBQztJQUVEOzs7O09BSUc7SUFDSCxTQUFTLENBQUMsR0F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XJhbSwgYmFzZSk7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICBjYXNlICdkJzpcbiAgICAgICAgICAgIGlmICh1cGRhdGUudmFsdWUgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICBsZXQgYmFzZSA9IHRoaXMubWFwIS5nZXQodXBkYXRlLnBhcmFtKSB8fCBbXTtcbiAgICAgICAgICAgICAgY29uc3QgaWR4ID0gYmFzZS5pbmRleE9mKHZhbHVlVG9TdHJpbmcodXBkYXRlLnZhbHVlKSk7XG4gICAgICAgICAgICAgIGlmIChpZHggIT09IC0xKSB7XG4gICAgICAgICAgICAgICAgYmFzZS5zcGxpY2UoaWR4LCAxKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBpZiAoYmFzZS5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5tYXAhLnNldCh1cGRhdGUucGFyYW0sIGJhc2UpO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMubWFwIS5kZWxldGUodXBkYXRlLnBhcmFtKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgdGhpcy5tYXAhLmRlbGV0ZSh1cGRhdGUucGFyYW0pO1xuICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgICB0aGlzLmNsb25lRnJvbSA9IHRoaXMudXBkYXRlcyA9IG51bGw7XG4gICAgfVxuICB9XG59XG4iXX0=
Note: See TracBrowser for help on using the repository browser.