mirror of
https://github.com/Lifeforge-app/lifeforge.git
synced 2026-06-28 23:05:48 +00:00
fix(shared): improve query parameter encoding in ForgeAPIClientController
This commit is contained in:
@@ -164,13 +164,21 @@ export class ForgeAPIClientController<
|
||||
let endpoint = `${this._route}`
|
||||
|
||||
if (this._input) {
|
||||
const queryParams = new URLSearchParams(
|
||||
Object.fromEntries(
|
||||
Object.entries(this._input).filter(([, value]) => value !== undefined)
|
||||
)
|
||||
)
|
||||
const queryString = Object.entries(this._input)
|
||||
.filter(([, value]) => value !== undefined)
|
||||
.map(([key, value]) => {
|
||||
// Manually encode to preserve + signs
|
||||
const encodedKey = encodeURIComponent(key)
|
||||
|
||||
endpoint += `?${queryParams.toString()}`
|
||||
const encodedValue = encodeURIComponent(String(value))
|
||||
|
||||
return `${encodedKey}=${encodedValue}`
|
||||
})
|
||||
.join('&')
|
||||
|
||||
if (queryString) {
|
||||
endpoint += `?${queryString}`
|
||||
}
|
||||
}
|
||||
|
||||
return endpoint
|
||||
|
||||
Reference in New Issue
Block a user