Browse Source

fix: Handle whitespace in api path

Signed-off-by: Pranav C Balan <pranavxc@gmail.com>
pull/292/head
Pranav C Balan 3 years ago
parent
commit
240a8fd323
  1. 4
      packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts
  2. 4
      packages/nocodb/src/lib/noco/rest/RestBaseCtrl.ts

4
packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts

@ -198,7 +198,7 @@ export class RestApiBuilder extends BaseApiBuilder<Noco> {
if (!rootPath) {
continue;
}
this.router.use(rootPath, router);
this.router.use(encodeURI(rootPath), router);
this.apiCount += routes.length;
this.controllers[meta.title] = new RestCtrl(this.app, this.models, meta.title, routes, rootPath, this.acls, middlewareBody);
@ -439,7 +439,7 @@ export class RestApiBuilder extends BaseApiBuilder<Noco> {
/* create table controllers and map the routes */
this.controllers[table.tn] = new RestCtrl(this.app, this.models, table.tn, routes, rootPath, this.acls, null);
this.controllers[table.tn].mapRoutes(router, this.customRoutes);
this.router.use(rootPath, router);
this.router.use(encodeURI(rootPath), router);
/* handle relational routes */
relationRoutes.push(async () => {

4
packages/nocodb/src/lib/noco/rest/RestBaseCtrl.ts

@ -32,7 +32,7 @@ export abstract class RestBaseCtrl {
handlers.push(this.postMiddleware);
router[addRoute.method](addRoute.path.slice(this.rootPath.length), ...handlers);
router[addRoute.method](encodeURI(addRoute.path.slice(this.rootPath.length)), ...handlers);
})
@ -55,7 +55,7 @@ export abstract class RestBaseCtrl {
handlers.push(this.postMiddleware);
router[route.type](route.path.slice(this.rootPath.length), ...handlers);
router[route.type](encodeURI(route.path.slice(this.rootPath.length)), ...handlers);
})
}

Loading…
Cancel
Save