mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:55:33 +00:00
fix: encode url params (#4055)
This commit is contained in:
parent
52d00aef58
commit
78ea107edb
@ -177,6 +177,32 @@ describe('utils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('decode associatedIndex', () => {
|
||||
const params = parseRequest({
|
||||
path: '/posts/a%2Fab/comments',
|
||||
method: 'POST',
|
||||
});
|
||||
expect(params).toMatchObject({
|
||||
resourceName: 'comments',
|
||||
associatedName: 'posts',
|
||||
associatedIndex: 'a/ab',
|
||||
actionName: 'create',
|
||||
});
|
||||
});
|
||||
|
||||
it('decode path', () => {
|
||||
const params = parseRequest({
|
||||
path: '/posts/%25E7%259A%2584%25E6%25B3%2595%252F%25E5%259B%25BD%25E9%2598%259F/comments',
|
||||
method: 'POST',
|
||||
});
|
||||
expect(params).toMatchObject({
|
||||
resourceName: 'comments',
|
||||
associatedName: 'posts',
|
||||
associatedIndex: '的法/国队',
|
||||
actionName: 'create',
|
||||
});
|
||||
});
|
||||
|
||||
it('store action', () => {
|
||||
const params = parseRequest({
|
||||
path: '/posts/1/comments',
|
||||
|
@ -189,6 +189,10 @@ export function parseRequest(request: ParseRequest, options: ParseOptions = {}):
|
||||
}
|
||||
}
|
||||
|
||||
if (params.associatedIndex) {
|
||||
params.associatedIndex = decodeURIComponent(params.associatedIndex);
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ export class APIClient {
|
||||
const target = {};
|
||||
const handler = {
|
||||
get: (_: any, actionName: string) => {
|
||||
let url = name.split('.').join(`/${of || '_'}/`);
|
||||
let url = name.split('.').join(`/${encodeURIComponent(of) || '_'}/`);
|
||||
url += `:${actionName}`;
|
||||
const config: AxiosRequestConfig = { url };
|
||||
if (['get', 'list'].includes(actionName)) {
|
||||
|
Loading…
Reference in New Issue
Block a user