1
0
Fork 0
mirror of synced 2024-07-04 14:01:27 +12:00
budibase/packages/server/middleware/routeHandlers/helpers.js

16 lines
516 B
JavaScript

exports.getRecordKey = (appname, wholePath) =>
this.getAppRelativePath(appname, wholePath)
.replace(`/api/files/`, "/")
.replace(`/api/lookup_field/`, "/")
.replace(`/api/record/`, "/")
.replace(`/api/listRecords/`, "/")
.replace(`/api/aggregates/`, "/")
exports.getAppRelativePath = (appname, wholePath) => {
const builderInstanceRegex = new RegExp(
`\\/_builder\\/instance\\/[^\\/]*\\/[^\\/]*\\/`
)
return wholePath.replace(builderInstanceRegex, "/").replace(`/${appname}`, "")
}