Skip to content

Commit f8aedc5

Browse files
vanceingallsclaude
andcommitted
fix(studio): a remote media url keeps its query when matching an asset
Two different videos at one remote path with different queries were treated as the same file, so Merge could delete the audio and use the wrong video's sound. Project-local srcs still drop query and hash. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 0cd908a commit f8aedc5

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎packages/studio/src/player/components/audioClipLink.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ describe("mediaAssetIdentity", () => {
4444
);
4545
expect(mediaAssetIdentity({ src: "" })).toBeNull();
4646
});
47+
48+
it("keeps a remote url's query, since it can select a different file", () => {
49+
expect(mediaAssetIdentity({ src: "https://cdn.example.com/v.mp4?id=1" })).not.toBe(
50+
mediaAssetIdentity({ src: "https://cdn.example.com/v.mp4?id=2" }),
51+
);
52+
expect(mediaAssetIdentity({ src: "https://cdn.example.com/v.mp4?id=1#t=3" })).toBe(
53+
mediaAssetIdentity({ src: "https://cdn.example.com/v.mp4?id=1" }),
54+
);
55+
});
4756
});
4857

4958
describe("expandToLinkedMembers", () => {

‎packages/studio/src/player/components/audioClipLink.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type LinkedElement = Pick<TimelineElement, "id" | "key" | "link"> & LinkScoped;
66
const keyOf = (element: Pick<TimelineElement, "id" | "key">) => element.key ?? element.id;
77

88
const SOURCE_BASE = "https://project.invalid/";
9+
const SOURCE_ORIGIN = new URL(SOURCE_BASE).origin;
910

1011
export function mediaAssetIdentity(
1112
element: Pick<TimelineElement, "src" | "sourceFile">,
@@ -14,7 +15,8 @@ export function mediaAssetIdentity(
1415
if (!src) return null;
1516
try {
1617
const url = new URL(src, new URL(element.sourceFile ?? "index.html", SOURCE_BASE));
17-
return decodeURIComponent(`${url.origin}${url.pathname}`);
18+
const query = url.origin === SOURCE_ORIGIN ? "" : url.search;
19+
return decodeURIComponent(`${url.origin}${url.pathname}${query}`);
1820
} catch {
1921
return null;
2022
}

0 commit comments

Comments
 (0)