77 * file that was distributed with this source code.
88 */
99
10- import qs from 'qs'
1110import cuid from 'cuid'
1211import fresh from 'fresh'
1312import typeIs from 'type-is'
1413import accepts from 'accepts'
1514import { isIP } from 'node:net'
16- import encodeUrl from 'encodeurl'
1715import proxyaddr from 'proxy-addr'
1816import { safeEqual } from '@poppinss/utils'
1917import lodash from '@poppinss/utils/lodash'
@@ -22,6 +20,7 @@ import type Encryption from '@adonisjs/encryption'
2220import { parse , UrlWithStringQuery } from 'node:url'
2321import { ServerResponse , IncomingMessage , IncomingHttpHeaders } from 'node:http'
2422
23+ import type { Qs } from './qs.js'
2524import { trustProxy } from './helpers.js'
2625import { CookieParser } from './cookies/parser.js'
2726import { RequestConfig } from './types/request.js'
@@ -37,6 +36,11 @@ import type { HttpContext } from './http_context/main.js'
3736 * using `request.request` property.
3837 */
3938export class Request extends Macroable {
39+ /**
40+ * Query string parser
41+ */
42+ #qsParser: Qs
43+
4044 /**
4145 * Encryption module to verify signed URLs and unsign/decrypt
4246 * cookies
@@ -102,10 +106,12 @@ export class Request extends Macroable {
102106 public request : IncomingMessage ,
103107 public response : ServerResponse ,
104108 encryption : Encryption ,
105- config : RequestConfig
109+ config : RequestConfig ,
110+ qsParser : Qs
106111 ) {
107112 super ( )
108113
114+ this . #qsParser = qsParser
109115 this . #config = config
110116 this . #encryption = encryption
111117 this . parsedUrl = parse ( this . request . url ! , false )
@@ -117,7 +123,7 @@ export class Request extends Macroable {
117123 */
118124 #parseQueryString( ) {
119125 if ( this . parsedUrl . query ) {
120- this . updateQs ( qs . parse ( this . parsedUrl . query , this . #config . qs ) )
126+ this . updateQs ( this . #qsParser . parse ( this . parsedUrl . query ) )
121127 this . #originalRequestData = { ...this . #requestData }
122128 }
123129 }
@@ -925,10 +931,10 @@ export class Request extends Macroable {
925931 return false
926932 }
927933
928- const queryString = qs . stringify ( rest )
934+ const queryString = this . #qsParser . stringify ( rest )
929935
930936 return queryString
931- ? safeEqual ( signedUrl , `${ this . url ( ) } ?${ encodeUrl ( queryString ) } ` )
937+ ? safeEqual ( signedUrl , `${ this . url ( ) } ?${ queryString } ` )
932938 : safeEqual ( signedUrl , this . url ( ) )
933939 }
934940
0 commit comments