mirror of
https://github.com/calesthio/OpenMontage.git
synced 2026-08-25 01:20:18 +08:00
Merge pull request #363 from prasanthsasikumar/upstream/fix-file-uri-slashes
fix(remotion): correct file:// URI slash count for POSIX absolute paths
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user