mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
Add automatic decoding of URIs when parsing queries
This commit is contained in:
parent
b43e563106
commit
939d93bfda
|
|
@ -163,14 +163,19 @@ export class RequestParser {
|
||||||
const url = new URL(this.request.url);
|
const url = new URL(this.request.url);
|
||||||
|
|
||||||
for (const [key, value] of url.searchParams.entries()) {
|
for (const [key, value] of url.searchParams.entries()) {
|
||||||
if (key.endsWith("[]")) {
|
if (decodeURIComponent(key).endsWith("[]")) {
|
||||||
const arrayKey = key.slice(0, -2) as keyof T;
|
const arrayKey = decodeURIComponent(key).slice(
|
||||||
|
0,
|
||||||
|
-2,
|
||||||
|
) as keyof T;
|
||||||
if (!result[arrayKey]) {
|
if (!result[arrayKey]) {
|
||||||
result[arrayKey] = [] as T[keyof T];
|
result[arrayKey] = [] as T[keyof T];
|
||||||
}
|
}
|
||||||
(result[arrayKey] as string[]).push(value);
|
(result[arrayKey] as string[]).push(decodeURIComponent(value));
|
||||||
} else {
|
} else {
|
||||||
result[key as keyof T] = value as T[keyof T];
|
result[key as keyof T] = decodeURIComponent(
|
||||||
|
value,
|
||||||
|
) as T[keyof T];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue