@@ -193,27 +193,29 @@ function validateRequest(request: HttpRequest): void {
193193 }
194194}
195195
196+ const parseQuery = ( searchParams : URLSearchParams ) : HttpQueryParameters => {
197+ const queryMap = new Object ( ) ;
198+ for ( const [ key , value ] of searchParams ) {
199+ const parameterName = decodeURIComponent ( key ) ;
200+ const parameterValue = decodeURIComponent ( value ) ;
201+
202+ let existingEntry = queryMap [ parameterName ] as string [ ] ;
203+ if ( ! existingEntry ) {
204+ existingEntry = new Array < string > ( ) ;
205+ queryMap [ parameterName ] = existingEntry ;
206+ }
207+ existingEntry . push ( parameterValue ) ;
208+ }
209+ const query = new HttpQueryParameters (
210+ queryMap as { string : string | string [ ] }
211+ ) ;
212+ return query ;
213+ } ;
214+
196215export class HttpRequestBuilder {
197216 static fromPath ( requestData : HttpRequestFromPath ) : HttpRequest {
198217 const url = new URL ( "file://" + requestData . path ) ;
199-
200- const queryMap = new Object ( ) ;
201- const queryString = url . search . substring ( 1 ) ;
202- for ( const entry of queryString . split ( "&" ) ) {
203- const pair = entry . split ( "=" ) ;
204- const parameterName = decodeURIComponent ( pair [ 0 ] ) ;
205- const parameterValue = decodeURIComponent ( pair [ 1 ] ) ;
206-
207- let existingEntry = queryMap [ parameterName ] as string [ ] ;
208- if ( ! existingEntry ) {
209- existingEntry = new Array < string > ( ) ;
210- queryMap [ parameterName ] = existingEntry ;
211- }
212- existingEntry . push ( parameterValue ) ;
213- }
214- const query = new HttpQueryParameters (
215- queryMap as { string : string | string [ ] }
216- ) ;
218+ const query = parseQuery ( url . searchParams ) ;
217219
218220 const request = {
219221 timestamp : requestData . timestamp ? requestData . timestamp : undefined ,
0 commit comments