diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-08-12 21:02:02 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-08-12 21:02:02 -0500 |
| commit | 96c14ccf5b776493e87244a1b1c2ad3345046d68 (patch) | |
| tree | 45e049621308f2a1837e4d58420741649868459d /src | |
| parent | e3b89745f0d1d18608d7183cb2af9e45c54d139e (diff) | |
| download | slskd-96c14ccf5b776493e87244a1b1c2ad3345046d68.tar.gz | |
url encode remaining routes
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/src/lib/chat.js | 6 | ||||
| -rw-r--r-- | src/web/src/lib/shares.js | 4 | ||||
| -rw-r--r-- | src/web/src/lib/transfers.js | 9 |
3 files changed, 10 insertions, 9 deletions
diff --git a/src/web/src/lib/chat.js b/src/web/src/lib/chat.js index e0205f4c..2b31bcd8 100644 --- a/src/web/src/lib/chat.js +++ b/src/web/src/lib/chat.js @@ -5,13 +5,13 @@ export const getAll = async () => { }; export const acknowledge = ({ username }) => { - return api.put(`/conversations/${username}`); + return api.put(`/conversations/${encodeURIComponent(username)}`); }; export const send = ({ username, message }) => { - return api.post(`/conversations/${username}`, JSON.stringify(message)); + return api.post(`/conversations/${encodeURIComponent(username)}`, JSON.stringify(message)); }; export const remove = ({ username }) => { - return api.delete(`/conversations/${username}`); + return api.delete(`/conversations/${encodeURIComponent(username)}`); };
\ No newline at end of file diff --git a/src/web/src/lib/shares.js b/src/web/src/lib/shares.js index f1d0373c..03fac7d6 100644 --- a/src/web/src/lib/shares.js +++ b/src/web/src/lib/shares.js @@ -6,7 +6,7 @@ export const getAll = async () => { export const get = async ({ id } = {}) => { if (!id) throw new Error('unable to get share: id is missing'); - return (await api.get(`/shares/${id}`)).data; + return (await api.get(`/shares/${encodeURIComponent(id)}`)).data; }; export const browseAll = async () => { @@ -15,7 +15,7 @@ export const browseAll = async () => { export const browse = async ({ id } = {}) => { if (!id) throw new Error('unable to get share contents: id is missing'); - return (await api.get(`/shares/${id}/contents`)).data; + return (await api.get(`/shares/${encodeURIComponent(id)}/contents`)).data; }; export const rescan = async () => { diff --git a/src/web/src/lib/transfers.js b/src/web/src/lib/transfers.js index d78a0ee8..18716fb9 100644 --- a/src/web/src/lib/transfers.js +++ b/src/web/src/lib/transfers.js @@ -1,7 +1,7 @@ import api from './api'; export const getAll = async ({ direction }) => { - const response = (await api.get(`/transfers/${direction}s`)).data; + const response = (await api.get(`/transfers/${encodeURIComponent(direction)}s`)).data; if (!Array.isArray(response)) { console.warn('got non-array response from transfers API', response); @@ -12,11 +12,12 @@ export const getAll = async ({ direction }) => { }; export const download = ({ username, files = [] }) => { - return api.post(`/transfers/downloads/${username}`, files); + return api.post(`/transfers/downloads/${encodeURIComponent(username)}`, files); }; export const cancel = ({ direction, username, id, remove = false }) => { - return api.delete(`/transfers/${direction}s/${username}/${id}?remove=${remove}`); + return api.delete( + `/transfers/${direction}s/${encodeURIComponent(username)}/${encodeURIComponent(id)}?remove=${remove}`); }; // 'Requested' @@ -31,7 +32,7 @@ export const cancel = ({ direction, username, id, remove = false }) => { // 'Completed, Rejected' export const getPlaceInQueue = ({ username, id }) => { - return api.get(`/transfers/downloads/${username}/${id}/position`); + return api.get(`/transfers/downloads/${encodeURIComponent(username)}/${id}/position`); }; export const isStateRetryable = (state) => |
