fix(ape): escaping parameters if they are part of the url

closes #5287
!nuf
This commit is contained in:
Miodec 2024-04-08 12:52:04 +02:00
parent 51aa1f1d0b
commit 163a0302e4
3 changed files with 18 additions and 9 deletions

View file

@ -22,10 +22,12 @@ export default class ApeKeys {
updates: { name?: string; enabled?: boolean }
): Ape.EndpointResponse<null> {
const payload = { ...updates };
return await this.httpClient.patch(`${BASE_PATH}/${apeKeyId}`, { payload });
const encoded = encodeURIComponent(apeKeyId);
return await this.httpClient.patch(`${BASE_PATH}/${encoded}`, { payload });
}
async delete(apeKeyId: string): Ape.EndpointResponse<null> {
return await this.httpClient.delete(`${BASE_PATH}/${apeKeyId}`);
const encoded = encodeURIComponent(apeKeyId);
return await this.httpClient.delete(`${BASE_PATH}/${encoded}`);
}
}

View file

@ -38,6 +38,7 @@ export default class Presets {
async delete(
presetId: string
): Ape.EndpointResponse<Ape.Presets.DeltePreset> {
return await this.httpClient.delete(`${BASE_PATH}/${presetId}`);
const encoded = encodeURIComponent(presetId);
return await this.httpClient.delete(`${BASE_PATH}/${encoded}`);
}
}

View file

@ -26,7 +26,8 @@ export default class Users {
}
async getNameAvailability(name: string): Ape.EndpointResponse<null> {
return await this.httpClient.get(`${BASE_PATH}/checkName/${name}`);
const encoded = encodeURIComponent(name);
return await this.httpClient.get(`${BASE_PATH}/checkName/${encoded}`);
}
async delete(): Ape.EndpointResponse<null> {
@ -90,8 +91,9 @@ export default class Users {
}
async removeResultFilterPreset(id: string): Ape.EndpointResponse<null> {
const encoded = encodeURIComponent(id);
return await this.httpClient.delete(
`${BASE_PATH}/resultFilterPresets/${id}`
`${BASE_PATH}/resultFilterPresets/${encoded}`
);
}
@ -111,12 +113,14 @@ export default class Users {
}
async deleteTag(tagId: string): Ape.EndpointResponse<null> {
return await this.httpClient.delete(`${BASE_PATH}/tags/${tagId}`);
const encoded = encodeURIComponent(tagId);
return await this.httpClient.delete(`${BASE_PATH}/tags/${encoded}`);
}
async deleteTagPersonalBest(tagId: string): Ape.EndpointResponse<null> {
const encoded = encodeURIComponent(tagId);
return await this.httpClient.delete(
`${BASE_PATH}/tags/${tagId}/personalBest`
`${BASE_PATH}/tags/${encoded}/personalBest`
);
}
@ -197,13 +201,15 @@ export default class Users {
async getProfileByUid(
uid: string
): Ape.EndpointResponse<SharedTypes.UserProfile> {
return await this.httpClient.get(`${BASE_PATH}/${uid}/profile?isUid`);
const encoded = encodeURIComponent(uid);
return await this.httpClient.get(`${BASE_PATH}/${encoded}/profile?isUid`);
}
async getProfileByName(
name: string
): Ape.EndpointResponse<SharedTypes.UserProfile> {
return await this.httpClient.get(`${BASE_PATH}/${name}/profile`);
const encoded = encodeURIComponent(name);
return await this.httpClient.get(`${BASE_PATH}/${encoded}/profile`);
}
async updateProfile(