From fb74fefe90003e35614079f197c72ef570c0cf4c Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Sat, 3 Oct 2026 15:45:58 -0700 Subject: [PATCH] fix(studio-server): HTML takes a folder-relative path only where its file exists, as the runtime reads it --- .../src/routes/files.renameReferences.test.ts | 53 ++++++++++++++++++- packages/studio-server/src/routes/files.ts | 42 +++++++++------ 2 files changed, 76 insertions(+), 19 deletions(-) diff --git a/packages/studio-server/src/routes/files.renameReferences.test.ts b/packages/studio-server/src/routes/files.renameReferences.test.ts index 20ee3ad25b..45c50d053b 100644 --- a/packages/studio-server/src/routes/files.renameReferences.test.ts +++ b/packages/studio-server/src/routes/files.renameReferences.test.ts @@ -338,12 +338,61 @@ describe("renaming a folder over the route", () => { join(project, "a", "style.css"), 'url(b/../logo.png) url(b/sub/../../logo.png) url(b\\.\\..\\logo.png) url("b/../in/logo.png") url("b/sub dir/../../logo.png") url("b/s,(;)/../../logo.png") url(b/image.png)', ); - writeFileSync(join(project, "index.html"), ''); expect((await renameIn(project, "a/b", "b/c")).status).toBe(200); expect(readFileSync(join(project, "a", "style.css"), "utf8")).toBe( 'url(b/../logo.png) url(b/sub/../../logo.png) url(b\\.\\..\\logo.png) url("b/../in/logo.png") url("b/sub dir/../../logo.png") url("b/s,(;)/../../logo.png") url(../b/c/image.png)', ); - expect(readFileSync(join(project, "index.html"), "utf8")).toBe(''); + }); + + it("in HTML takes the folder reading only where its file exists, else leaves the root path to the root pass", async () => { + const project = mkdtempSync(join(tmpdir(), "hf-rename-refs-")); + dirs.push(project); + mkdirSync(join(project, "assets")); + mkdirSync(join(project, "compositions", "assets"), { recursive: true }); + writeFileSync(join(project, "assets", "logo.png"), "x"); + writeFileSync(join(project, "compositions", "assets", "bg.png"), "x"); + writeFileSync( + join(project, "compositions", "hero.html"), + '', + ); + + expect((await renameIn(project, "compositions/assets", "compositions/media")).status).toBe(200); + expect(readFileSync(join(project, "compositions", "hero.html"), "utf8")).toBe( + '', + ); + }); + + it("in HTML gives a path the runtime reads from the root to the root pass, where both readings match", async () => { + const project = mkdtempSync(join(tmpdir(), "hf-rename-refs-")); + dirs.push(project); + mkdirSync(join(project, "scenes", "scenes"), { recursive: true }); + writeFileSync(join(project, "scenes", "scenes", "clip.mp4"), "x"); + writeFileSync(join(project, "scenes", "intro.html"), '