test: titles in project previews (#45051)

* fix: trim titles before injecting into iframes

Surrounding whitespace isn't useful

* test: check preview iframe has correct title
This commit is contained in:
Oliver Eyton-Williams
2022-02-10 18:57:50 +01:00
committed by GitHub
parent 44e2bce920
commit 5f06b7805c
3 changed files with 83 additions and 30 deletions

View File

@@ -213,7 +213,9 @@ export function updateProjectPreview(buildData, document) {
const titleMatch = buildData?.sources?.index?.match(
/<title>(.*?)<\/title>/
);
const frameTitle = titleMatch ? titleMatch[1] + ' preview' : 'preview';
const frameTitle = titleMatch
? titleMatch[1].trim() + ' preview'
: 'preview';
createProjectPreviewFramer(document, frameTitle)(buildData);
} else {
throw new Error(