(options: HttpParamsOptions = {} as HttpParamsOptions)
| 169 | private cloneFrom: HttpParams | null = null; |
| 170 | |
| 171 | constructor(options: HttpParamsOptions = {} as HttpParamsOptions) { |
| 172 | this.encoder = options.encoder || new HttpUrlEncodingCodec(); |
| 173 | if (options.fromString) { |
| 174 | if (options.fromObject) { |
| 175 | throw new RuntimeError( |
| 176 | RuntimeErrorCode.CANNOT_SPECIFY_BOTH_FROM_STRING_AND_FROM_OBJECT, |
| 177 | ngDevMode && 'Cannot specify both fromString and fromObject.', |
| 178 | ); |
| 179 | } |
| 180 | this.map = paramParser(options.fromString, this.encoder); |
| 181 | } else if (!!options.fromObject) { |
| 182 | this.map = new Map<string, string[]>(); |
| 183 | Object.keys(options.fromObject).forEach((key) => { |
| 184 | const value = (options.fromObject as any)[key]; |
| 185 | // convert the values to strings |
| 186 | const values = Array.isArray(value) ? value.map(valueToString) : [valueToString(value)]; |
| 187 | this.map!.set(key, values); |
| 188 | }); |
| 189 | } else { |
| 190 | this.map = null; |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * Reports whether the body includes one or more values for a given parameter. |
nothing calls this directly
no test coverage detected