fix(cli): check keeps copy windows for videos with #, ? or % in the name (#8669)

This commit is contained in:
Miguel Ángel
2026-11-24 08:39:25 +00:00
committed by GitHub
parent 0ee98f87d0
commit 5e1a490c80
2 changed files with 30 additions and 1 deletions
@@ -2554,6 +2554,34 @@ describe("finding frame capture", () => {
}
});
// fails without the fix: the name was decoded twice, so these files got no copy window
it("keeps the copy window of a video whose name has #, ? or %", async () => {
const dir = mkdtempSync(join(tmpdir(), "finding-windows-names-"));
// Windows refuses ? in a file name.
const names = [
"clip #1.mov",
"50% off.mov",
...(process.platform === "win32" ? [] : ["a?b.mov"]),
];
for (const name of names) writeFileSync(join(dir, name), "");
installSessionMock(fakePage());
mocks.bundleWithLocalizedFonts.mockResolvedValueOnce(
`<html><body>${names.map((name) => `<video src="${encodeURIComponent(name)}" data-duration="5"></video>`).join("")}</body></html>`,
);
mocks.proxyWindowSeconds.mockClear();
mocks.proxyWindowSeconds.mockResolvedValue(30);
try {
await captureFindingFrames({ ...PROJECT, dir }, DEFAULT_CHECK_OPTIONS, [
{ time: 1, filename: "a.png" },
]);
expect(vi.mocked(serveStaticProjectHtml).mock.calls.at(-1)?.[5]).toEqual(
new Map(names.map((name) => [join(dir, name), 30])),
);
} finally {
rmSync(dir, { recursive: true, force: true });
}
});
it("closes the session when a later screenshot fails", async () => {
const dir = mkdtempSync(join(tmpdir(), "finding-frames-failure-"));
const page = fakePage();
+2 -1
View File
@@ -45,6 +45,7 @@ import {
import { resolveAutoProxy } from "./projectConfig.js";
import { findStageProxyBox } from "./compositionViewport.js";
import { mediaUsedSeconds } from "./mediaUsedSeconds.js";
import { encodeUrlPath } from "@hyperframes/parsers";
import type { PreviewProxyBox } from "@hyperframes/core";
import { terminalText } from "@hyperframes/core/terminal-text";
import { injectTagsAtHeadStart } from "@hyperframes/core/compiler/html-document";
@@ -223,7 +224,7 @@ async function copyWindows(
[...pathnames].map(async (pathname) => {
const seconds = used.get(pathname);
if (seconds === undefined) return;
const sourcePath = projectLocalFile(projectDir, pathname);
const sourcePath = projectLocalFile(projectDir, encodeUrlPath(pathname));
if (!sourcePath) return;
const window = await proxyWindowSeconds(sourcePath, seconds);
if (window !== undefined) windows.set(sourcePath, window);