Skip to content

Commit 41a3455

Browse files
committed
chore: wip
1 parent b78dc0a commit 41a3455

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

.stacks/core/router/src/request.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,23 @@ interface RequestData {
55
type RouteParams = { [key: string]: string } | null
66

77
export class Request {
8-
private query: { [key: string]: string } = {}
8+
private query: RequestData = {}
99
private params: RouteParams = null
1010

1111
public addQuery(url: URL): void {
12-
const query = url.searchParams
13-
14-
const paramObject: RequestData = {}
15-
16-
for (const [key, value] of query.entries())
17-
paramObject[key] = value
18-
19-
this.query = paramObject
12+
this.query = Object.fromEntries(url.searchParams)
2013
}
2114

2215
public get(element: string): string | number | undefined {
2316
return this.query[element]
2417
}
2518

26-
public all(): { [key: string]: string } {
19+
public all(): RequestData {
2720
return this.query
2821
}
2922

3023
public has(element: string): boolean {
31-
return Object.prototype.hasOwnProperty.call(this.query, element)
24+
return element in this.query
3225
}
3326

3427
public isEmpty(): boolean {
@@ -41,7 +34,7 @@ export class Request {
4134

4235
if (match?.groups)
4336
this.params = match?.groups
44-
};
37+
}
4538

4639
public getParams(key: string): number | string | null {
4740
return this.params ? (this.params[key] || null) : null

0 commit comments

Comments
 (0)