fix: update key handling in StorageR2Adapter to conditionally prepend keyPrefix

- Modified getKey method to prepend keyPrefix only if it is not empty, ensuring correct key formatting.
This commit is contained in:
dswbx
2025-10-26 21:04:37 +01:00
parent 0dbf71e6b5
commit 574b37abcd

View File

@@ -177,7 +177,10 @@ export class StorageR2Adapter extends StorageAdapter {
}
protected getKey(key: string) {
return `${this.keyPrefix}/${key}`.replace(/^\/\//, "/");
if (this.keyPrefix.length > 0) {
return `${this.keyPrefix}/${key}`.replace(/^\/\//, "/");
}
return key;
}
toJSON(secrets?: boolean) {