Skip to content

Commit

Permalink
feat: Use URL to append path safely to baseURL (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazmi35 authored Oct 26, 2023
1 parent 45b1ae7 commit 0a008e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Structures/REST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class REST {
public async get<T>(route: string, init?: RequestInit | undefined): Promise<T> {
await this.queue.wait();
try {
return fetch(`${this.url}${route}`, { headers: this.headers, ...init }, FetchResultTypes.JSON);
return fetch(new URL(route, this.url), { headers: this.headers, ...init }, FetchResultTypes.JSON);
} finally {
this.queue.shift();
}
Expand All @@ -96,7 +96,7 @@ export class REST {
public async post<T>(route: string, init?: RequestInit | undefined): Promise<T> {
await this.queue.wait();
try {
return fetch(`${this.url}${route}`, { headers: this.headers, method: 'POST', ...init }, FetchResultTypes.JSON);
return fetch(new URL(route, this.url), { headers: this.headers, method: 'POST', ...init }, FetchResultTypes.JSON);
} finally {
this.queue.shift();
}
Expand Down

0 comments on commit 0a008e7

Please sign in to comment.