Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/daemon/src/routes/static-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ function normalizeDesignSystemCraftApplies(value: unknown): string[] | undefined
export function assembleExample(templateHtml: string, slidesHtml: string, title: string) {
return templateHtml
.replace('<!-- SLIDES_HERE -->', slidesHtml)
.replace(/<title>.*?<\/title>/, `<title>${title} | Open Design Example</title>`);
.replace(/<title>.*?<\/title>/, () => `<title>${title} | Open Design Example</title>`);
}

export function rewriteSkillAssetUrls(
Expand Down
6 changes: 4 additions & 2 deletions apps/desktop/src/main/artifact-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ function injectBaseHref(doc: string, baseHref: string | undefined): string {

function injectTitle(doc: string, title: string): string {
const tag = `<title>${escapeText(title)}</title>`;
if (/<title[^>]*>.*?<\/title>/is.test(doc)) return doc.replace(/<title[^>]*>.*?<\/title>/is, tag);
if (/<head[^>]*>/i.test(doc)) return doc.replace(/<head[^>]*>/i, (m) => `${m}${tag}`);
if (/<title[^>]*>.*?<\/title>/is.test(doc))
return doc.replace(/<title[^>]*>.*?<\/title>/is, () => tag);
if (/<head[^>]*>/i.test(doc))
return doc.replace(/<head[^>]*>/i, (m) => `${m}${tag}`);
return doc;
}

Expand Down
9 changes: 6 additions & 3 deletions apps/desktop/src/main/pdf-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,12 @@ function injectBaseHref(doc: string, baseHref: string | undefined): string {

function injectTitle(doc: string, title: string): string {
const tag = `<title>${escapeHtmlText(title)}</title>`;
if (/<title[^>]*>.*?<\/title>/is.test(doc)) return doc.replace(/<title[^>]*>.*?<\/title>/is, tag);
if (/<head[^>]*>/i.test(doc)) return doc.replace(/<head[^>]*>/i, (match) => `${match}${tag}`);
if (/<html[^>]*>/i.test(doc)) return doc.replace(/<html[^>]*>/i, (match) => `${match}<head>${tag}</head>`);
if (/<title[^>]*>.*?<\/title>/is.test(doc))
return doc.replace(/<title[^>]*>.*?<\/title>/is, () => tag);
if (/<head[^>]*>/i.test(doc))
return doc.replace(/<head[^>]*>/i, (match) => `${match}${tag}`);
if (/<html[^>]*>/i.test(doc))
return doc.replace(/<html[^>]*>/i, (match) => `${match}<head>${tag}</head>`);
return `<!doctype html><html><head>${tag}</head><body>${doc}</body></html>`;
}

Expand Down
Loading