fix(remotion): correct file:// slash count for POSIX absolute paths

resolveAsset() built `file:///` + a POSIX absolute path (which already
starts with /), yielding `file:////Users/...` (four slashes). Split the
branch: POSIX paths get `file://` + path (three slashes total), Windows
drive paths keep the explicit extra slash. Same fix across the five
compositions that share resolveAsset().

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit 226a52d1e9b56b9da8b94e8e95ef6b753666abb0)
This commit is contained in:
Prasanth Sasikumar
2026-07-11 22:32:18 -04:00
parent f633b5f428
commit 9c9b1beeb5
6 changed files with 54 additions and 6 deletions

View File

@@ -19,7 +19,15 @@ function resolveAsset(src: string): string {
}
const clean = src.replace(/^file:\/\/\/?/, "");
if (clean.startsWith("/") || /^[A-Za-z]:[/\\]/.test(clean)) {
return `file:///${clean.replace(/\\/g, "/")}`;
const posix = clean.replace(/\\/g, "/");
// POSIX absolute paths already have a leading "/" — file:// + posix
// gives exactly three slashes. Windows drive paths (C:/...) need the
// extra slash added explicitly. Do not merge these branches — adding
// "file:///" unconditionally double-slashes POSIX paths (file:////...).
if (posix.startsWith("/")) {
return `file://${posix}`;
}
return `file:///${posix}`;
}
return staticFile(clean);
}

View File

@@ -26,7 +26,15 @@ function resolveAsset(src: string): string {
if (src.startsWith("http://") || src.startsWith("https://") || src.startsWith("data:")) return src;
const clean = src.replace(/^file:\/\/\/?/, "");
if (clean.startsWith("/") || /^[A-Za-z]:[\\/]/.test(clean)) {
return `file:///${clean.replace(/\\/g, "/")}`;
const posix = clean.replace(/\\/g, "/");
// POSIX absolute paths already have a leading "/" — file:// + posix
// gives exactly three slashes. Windows drive paths (C:/...) need the
// extra slash added explicitly. Do not merge these branches — adding
// "file:///" unconditionally double-slashes POSIX paths (file:////...).
if (posix.startsWith("/")) {
return `file://${posix}`;
}
return `file:///${posix}`;
}
return staticFile(clean);
}

View File

@@ -22,7 +22,15 @@ function resolveAsset(src: string): string {
// Absolute paths (Unix: /foo, Windows: C:\foo or C:/foo) — convert to file:// URI
// staticFile() only accepts relative paths within public/, so absolute paths must bypass it
if (clean.startsWith("/") || /^[A-Za-z]:[\\/]/.test(clean)) {
return `file:///${clean.replace(/\\/g, "/")}`;
const posix = clean.replace(/\\/g, "/");
// POSIX absolute paths already have a leading "/" — file:// + posix
// gives exactly three slashes. Windows drive paths (C:/...) need the
// extra slash added explicitly. Do not merge these branches — adding
// "file:///" unconditionally double-slashes POSIX paths (file:////...).
if (posix.startsWith("/")) {
return `file://${posix}`;
}
return `file:///${posix}`;
}
return staticFile(clean);
}

View File

@@ -19,7 +19,15 @@ function resolveAsset(src: string): string {
if (src.startsWith("http://") || src.startsWith("https://") || src.startsWith("data:")) return src;
const clean = src.replace(/^file:\/\/\/?/, "");
if (clean.startsWith("/") || /^[A-Za-z]:[\\/]/.test(clean)) {
return `file:///${clean.replace(/\\/g, "/")}`;
const posix = clean.replace(/\\/g, "/");
// POSIX absolute paths already have a leading "/" — file:// + posix
// gives exactly three slashes. Windows drive paths (C:/...) need the
// extra slash added explicitly. Do not merge these branches — adding
// "file:///" unconditionally double-slashes POSIX paths (file:////...).
if (posix.startsWith("/")) {
return `file://${posix}`;
}
return `file:///${posix}`;
}
return staticFile(clean);
}

View File

@@ -46,7 +46,15 @@ function resolveAsset(src: string): string {
}
const clean = src.replace(/^file:\/\/\/?/, "");
if (clean.startsWith("/") || /^[A-Za-z]:[\\/]/.test(clean)) {
return `file:///${clean.replace(/\\/g, "/")}`;
const posix = clean.replace(/\\/g, "/");
// POSIX absolute paths already have a leading "/" — file:// + posix
// gives exactly three slashes. Windows drive paths (C:/...) need the
// extra slash added explicitly. Do not merge these branches — adding
// "file:///" unconditionally double-slashes POSIX paths (file:////...).
if (posix.startsWith("/")) {
return `file://${posix}`;
}
return `file:///${posix}`;
}
return staticFile(clean);
}

View File

@@ -90,7 +90,15 @@ function resolveAsset(src: string): string {
}
const clean = src.replace(/^file:\/\/\/?/, "");
if (clean.startsWith("/") || /^[A-Za-z]:[\\/]/.test(clean)) {
return `file:///${clean.replace(/\\/g, "/")}`;
const posix = clean.replace(/\\/g, "/");
// POSIX absolute paths already have a leading "/" — file:// + posix
// gives exactly three slashes. Windows drive paths (C:/...) need the
// extra slash added explicitly. Do not merge these branches — adding
// "file:///" unconditionally double-slashes POSIX paths (file:////...).
if (posix.startsWith("/")) {
return `file://${posix}`;
}
return `file:///${posix}`;
}
return staticFile(clean);
}