mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 08:32:45 +00:00
fix(studio-server): a folder-relative url() in a minified page style follows a rename
This commit is contained in:
@@ -409,7 +409,7 @@ export function referenceRewriter(
|
||||
const MAX_REST = 256;
|
||||
const restAfter = (text: string, end: number) =>
|
||||
/^[^"'`<>\r\n]*/.exec(text.slice(end, end + MAX_REST))![0];
|
||||
const REFERENCE_END = /^(?:$|\)(?=$|[\s;,])|[?#]|,\s|\s+\d+(?:\.\d+)?[wx](?![\w.]))/;
|
||||
const REFERENCE_END = /^(?:$|\)(?=$|[\s;,}!)/])|[?#]|,\s|\s+\d+(?:\.\d+)?[wx](?![\w.]))/;
|
||||
|
||||
function reaches(targets: ReadonlySet<string>, path: string): boolean {
|
||||
for (let i = 0; i <= path.length; i++)
|
||||
|
||||
@@ -838,4 +838,19 @@ describe("renaming a folder over the route", () => {
|
||||
'url("old clips/a.png") url(takes/a.png)',
|
||||
);
|
||||
});
|
||||
|
||||
// fails without the fix: a page's minified <style> ended a url() with `}`, so its folder reading never matched.
|
||||
it("in HTML follows a folder-relative url() in a minified style", async () => {
|
||||
const project = mkdtempSync(join(tmpdir(), "hf-rename-refs-"));
|
||||
dirs.push(project);
|
||||
mkdirSync(join(project, "assets", "clips"), { recursive: true });
|
||||
writeFileSync(join(project, "assets", "clips", "a.png"), "x");
|
||||
const style = (folder: string) =>
|
||||
`<style>.a{background:url(${folder}/a.png)}.b{background:url(${folder}/a.png)!important}` +
|
||||
`.c{background:image-set(url(${folder}/a.png) 1x)}</style>`;
|
||||
writeFileSync(join(project, "assets", "page.html"), style("clips"));
|
||||
const response = await renameIn(project, "assets/clips", "assets/takes");
|
||||
expect(response.status).toBe(200);
|
||||
expect(readFileSync(join(project, "assets", "page.html"), "utf8")).toBe(style("takes"));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user