Skip to content

Commit 16e3c66

Browse files
author
Joel Lee
committed
refactor: use URLQueryParams
1 parent 20f3f16 commit 16e3c66

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/GoTrueApi.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default class GoTrueApi {
6767
options: {
6868
redirectTo?: string
6969
scopes?: string
70-
queryParams?: Record<string, string>
70+
queryParams?: { [key: string]: string }
7171
}
7272
) {
7373
const urlParams: string[] = [`provider=${encodeURIComponent(provider)}`]
@@ -78,9 +78,8 @@ export default class GoTrueApi {
7878
urlParams.push(`scopes=${encodeURIComponent(options.scopes)}`)
7979
}
8080
if(options?.queryParams) {
81-
for(const [param, value] of Object.entries(options.queryParams)) {
82-
urlParams.push(`${encodeURIComponent(param)}=${encodeURIComponent(value)}`)
83-
}
81+
const query = new URLSearchParams(options.queryParams)
82+
urlParams.push(`${query}`)
8483
}
8584
return `${this.url}/authorize?${urlParams.join('&')}`
8685
}

src/GoTrueClient.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export default class GoTrueClient {
194194
shouldCreateUser?: boolean
195195
scopes?: string
196196
captchaToken?: string
197-
queryParams?: Record<string, string>
197+
queryParams?: { [key: string]: string }
198198
} = {}
199199
): Promise<{
200200
session: Session | null
@@ -552,7 +552,7 @@ export default class GoTrueClient {
552552
options: {
553553
redirectTo?: string
554554
scopes?: string
555-
queryParams?: Record<string, string>
555+
queryParams?: { [key: string]: string }
556556
} = {}
557557
) {
558558
const url: string = this.api.getUrlForProvider(provider, {

0 commit comments

Comments
 (0)