Skip to content

Commit 4991996

Browse files
committed
refactor: use safeDecodeURI for parsing query and pathname from a uri
1 parent ebfd3da commit 4991996

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/redirect.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* file that was distributed with this source code.
88
*/
99

10-
import { parse } from 'node:url'
1110
import type { IncomingMessage } from 'node:http'
1211

1312
import debug from './debug.ts'
@@ -22,6 +21,7 @@ import type {
2221
GetRoutesForMethod,
2322
RouteBuilderArguments,
2423
} from './types/url_builder.ts'
24+
import { safeDecodeURI } from './utils.ts'
2525

2626
/**
2727
* Exposes the API to construct redirect routes
@@ -194,7 +194,7 @@ export class Redirect {
194194
let query: Record<string, any> = {}
195195

196196
const referrerUrl = this.#getReferrerUrl()
197-
const url = parse(referrerUrl)
197+
const url = safeDecodeURI(referrerUrl, false)
198198

199199
debug('referrer url "%s"', referrerUrl)
200200
debug('referrer base url "%s"', url.pathname)
@@ -247,7 +247,7 @@ export class Redirect {
247247
* Extract query string from the current URL
248248
*/
249249
if (this.#forwardQueryString) {
250-
query = this.#qs.parse(parse(this.#request.url!).query || '')
250+
query = this.#qs.parse(safeDecodeURI(this.#request.url!, false).query || '')
251251
}
252252

253253
/**

0 commit comments

Comments
 (0)