sanitizing client lib URL

This commit is contained in:
Martin McKeaveney 2021-05-24 21:30:46 +01:00
parent 934ccb8bb9
commit f3198aec98
2 changed files with 8 additions and 1 deletions

View File

@ -34,11 +34,15 @@ function sanitizeKey(input) {
return sanitize(sanitizeBucket(input)).replace(/\\/g, "/")
}
exports.sanitizeKey = sanitizeKey
// simply handles the dev app to app conversion
function sanitizeBucket(input) {
return input.replace(new RegExp(APP_DEV_PREFIX, "g"), APP_PREFIX)
}
exports.sanitizeBucket = sanitizeBucket
function publicPolicy(bucketName) {
return {
Version: "2012-10-17",

View File

@ -1,6 +1,7 @@
const env = require("../environment")
const { OBJ_STORE_DIRECTORY, ObjectStoreBuckets } = require("../constants")
const { getAllApps } = require("@budibase/auth/db")
const { sanitizeKey } = require("@budibase/auth/src/objectStore")
const BB_CDN = "https://cdn.app.budi.live/assets"
@ -43,7 +44,9 @@ exports.objectStoreUrl = () => {
*/
exports.clientLibraryPath = appId => {
if (env.isProd()) {
return `${exports.objectStoreUrl()}/${appId}/budibase-client.js`
return `${exports.objectStoreUrl()}/${sanitizeKey(
appId
)}/budibase-client.js`
} else {
return `/api/assets/client`
}