budibase/packages/server/middleware/routeHandlers/helpers.js

16 lines
516 B
JavaScript
Raw Normal View History

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}`, "")
}