UNPKG

2.39 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. 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 * @deprecated see https://angular.io/guide/http
10 * @publicApi
11 **/
12export declare class QueryEncoder {
13 encodeKey(key: string): string;
14 encodeValue(value: string): string;
15}
16/**
17 * Map-like representation of url search parameters, based on
18 * [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) in the url living standard,
19 * with several extensions for merging URLSearchParams objects:
20 * - setAll()
21 * - appendAll()
22 * - replaceAll()
23 *
24 * This class accepts an optional second parameter of ${@link QueryEncoder},
25 * which is used to serialize parameters before making a request. By default,
26 * `QueryEncoder` encodes keys and values of parameters using `encodeURIComponent`,
27 * and then un-encodes certain characters that are allowed to be part of the query
28 * according to IETF RFC 3986: https://tools.ietf.org/html/rfc3986.
29 *
30 * These are the characters that are not encoded: `! $ \' ( ) * + , ; A 9 - . _ ~ ? /`
31 *
32 * If the set of allowed query characters is not acceptable for a particular backend,
33 * `QueryEncoder` can be subclassed and provided as the 2nd argument to URLSearchParams.
34 *
35 * ```
36 * import {URLSearchParams, QueryEncoder} from '@angular/http';
37 * class MyQueryEncoder extends QueryEncoder {
38 * encodeKey(k: string): string {
39 * return myEncodingFunction(k);
40 * }
41 *
42 * encodeValue(v: string): string {
43 * return myEncodingFunction(v);
44 * }
45 * }
46 *
47 * let params = new URLSearchParams('', new MyQueryEncoder());
48 * ```
49 * @deprecated see https://angular.io/guide/http
50 * @publicApi
51 */
52export declare class URLSearchParams {
53 rawParams: string;
54 private queryEncoder;
55 paramsMap: Map<string, string[]>;
56 constructor(rawParams?: string, queryEncoder?: QueryEncoder);
57 clone(): URLSearchParams;
58 has(param: string): boolean;
59 get(param: string): string | null;
60 getAll(param: string): string[];
61 set(param: string, val: string): void;
62 setAll(searchParams: URLSearchParams): void;
63 append(param: string, val: string): void;
64 appendAll(searchParams: URLSearchParams): void;
65 replaceAll(searchParams: URLSearchParams): void;
66 toString(): string;
67 delete(param: string): void;
68}