Pass one at unfucking the stupid file encoding issues
This commit is contained in:
parent
24417ac516
commit
3e65a2d055
10 changed files with 33 additions and 19 deletions
|
@ -3,7 +3,7 @@ import http from '@/api/http';
|
|||
export default (server: string, file: string): Promise<string> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get(`/api/client/servers/${server}/files/contents`, {
|
||||
params: { file: encodeURI(decodeURI(file)) },
|
||||
params: { file },
|
||||
transformResponse: res => res,
|
||||
responseType: 'text',
|
||||
})
|
||||
|
|
|
@ -18,7 +18,9 @@ export interface FileObject {
|
|||
|
||||
export default async (uuid: string, directory?: string): Promise<FileObject[]> => {
|
||||
const { data } = await http.get(`/api/client/servers/${uuid}/files/list`, {
|
||||
params: { directory: encodeURI(directory ?? '/') },
|
||||
// At this point the directory is still encoded so we need to decode it since axios
|
||||
// will automatically re-encode this value before sending it along in the request.
|
||||
params: { directory: decodeURI(directory ?? '/') },
|
||||
});
|
||||
|
||||
return (data.data || []).map(rawDataToFileObject);
|
||||
|
|
|
@ -2,7 +2,7 @@ import http from '@/api/http';
|
|||
|
||||
export default async (uuid: string, file: string, content: string): Promise<void> => {
|
||||
await http.post(`/api/client/servers/${uuid}/files/write`, content, {
|
||||
params: { file: encodeURI(decodeURI(file)) },
|
||||
params: { file },
|
||||
headers: {
|
||||
'Content-Type': 'text/plain',
|
||||
},
|
||||
|
|
Reference in a new issue