Files
artcraft-services/packages/components/src/api/BucketConfig.ts
T

29 lines
754 B
TypeScript

class BucketConfig {
isLocalDev: boolean;
constructor() {
this.isLocalDev = (
document.location.host.includes("localhost") ||
document.location.host.includes("jungle.horse") ||
document.location.host.startsWith("dev."));
}
// TODO: Prevent callers with undefined/null paths
getGcsUrl(bucketRelativePath: string | undefined | null) : string {
let bucket = this.getBucket();
let path = bucketRelativePath;
if (path !== undefined && path !== null && !path.startsWith('/')) {
path = '/' + path;
}
return `https://storage.googleapis.com/${bucket}${path}`;
}
private getBucket() : string {
return this.isLocalDev? 'dev-vocodes-public' : 'vocodes-public';
}
}
export { BucketConfig }