mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 00:10:57 +00:00
Refactor file handling to improve URL safety and enhance file viewing capabilities across components
This commit is contained in:
@@ -65,7 +65,14 @@ export class MinioService {
|
||||
}
|
||||
|
||||
const url = new URL(trimmed);
|
||||
const parts = url.pathname.split("/").filter(Boolean);
|
||||
// `url.pathname` percent-encodes the object key (e.g. a space becomes
|
||||
// "%20"), but MinIO stores the key with its literal characters. Decode each
|
||||
// segment so the recovered key matches what was uploaded — otherwise a file
|
||||
// whose name had spaces/unicode 404s with "specified key does not exist".
|
||||
const parts = url.pathname
|
||||
.split("/")
|
||||
.filter(Boolean)
|
||||
.map((segment) => decodeURIComponent(segment));
|
||||
if (parts[0] === this.bucket) {
|
||||
parts.shift();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user