mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-04 21:17:30 +00:00
fix(studio-server): a page follows a folder moved out of its own folder
This commit is contained in:
@@ -791,6 +791,20 @@ describe("renaming a folder over the route", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("in HTML follows a folder moved out of the page's folder", async () => {
|
||||
const project = mkdtempSync(join(tmpdir(), "hf-rename-refs-"));
|
||||
dirs.push(project);
|
||||
mkdirSync(join(project, "assets", "clips"), { recursive: true });
|
||||
mkdirSync(join(project, "media"));
|
||||
writeFileSync(join(project, "assets", "clips", "a.png"), "x");
|
||||
writeFileSync(join(project, "assets", "i.html"), '<img src="clips/a.png">');
|
||||
|
||||
expect((await renameIn(project, "assets/clips", "media/clips")).status).toBe(200);
|
||||
expect(readFileSync(join(project, "assets", "i.html"), "utf8")).toBe(
|
||||
'<img src="../media/clips/a.png">',
|
||||
);
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
@@ -1126,9 +1126,10 @@ function updateReferences(
|
||||
.filter((path) => path.startsWith(`${dir}/`))
|
||||
.map((path) => path.slice(at + 1));
|
||||
const [from, to] = [oldPath.slice(at + 1), posix.relative(dir, newPath)];
|
||||
const everywhere = filesOnly(existing.map((path) => posix.relative(dir, path)));
|
||||
parentFolderEdits.set(dir, {
|
||||
css: referenceEdits(from, to, isDirectory, inside, { targets: null }),
|
||||
html: referenceEdits(from, to, isDirectory, inside, { targets: filesOnly(inside) }),
|
||||
html: referenceEdits(from, to, isDirectory, inside, { targets: everywhere }),
|
||||
});
|
||||
}
|
||||
let updatedCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user