Skip to content

Commit 8995fc6

Browse files
authored
Improve URL generation for audio media objects in GCS (#3434)
1 parent 533eef4 commit 8995fc6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

helm-frontend/src/components/MediaObjectDisplay.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function MediaObjectDisplay({ mediaObject }: Props) {
2727
}
2828
const url = getBenchmarkEndpoint(
2929
mediaObject.location
30-
.replace("benchmark_output/", "")
30+
.replace(/^.*benchmark_output\//, "")
3131
.replace("prod_env/", "../"),
3232
);
3333
return (

helm-frontend/src/utils/getBenchmarkEndpoint.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ export default function getBenchmarkEndpoint(path: string): string {
22
if (path.startsWith("http://") || path.startsWith("https://")) {
33
return path;
44
}
5-
return `${window.BENCHMARK_OUTPUT_BASE_URL.replace(/\/$/, "")}/${path.replace(
6-
/^\//,
7-
"",
8-
)}`;
5+
return `${window.BENCHMARK_OUTPUT_BASE_URL.replace(/\/$/, "")}/${path
6+
.replace(/^\//, "")
7+
.split("/")
8+
.map((component) => encodeURIComponent(component))
9+
.join("/")}`;
910
}

0 commit comments

Comments
 (0)