-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Ensure empty file prerender state works no matter how meta tag l…
…ooks It seems in newer versions of puppeteer, it can be serialized as `<meta>` without closing tag, which breaks with the current setup. Now, we handle open, open+close, and self-closing tags.
- Loading branch information
Showing
3 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
packages/ember-build-prerender/lib/utils/fix-prerender-in-empty-file.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = function fixPrerenderInEmptyFile(emptyFileContent) { | ||
return emptyFileContent.replace( | ||
'<meta name="prerender-config" content="should-prerender"', | ||
'<meta name="prerender-config" content="skip"' | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/test-app/node-tests/unit/fix-prerender-in-empty-file-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const { expect } = require('chai'); | ||
const fixPrerenderInEmptyFile = require('ember-build-prerender/lib/utils/fix-prerender-in-empty-file'); | ||
|
||
describe('fix-prerender-in-empty-file', function () { | ||
it('it works with empty string', async function () { | ||
let source = ``; | ||
let expected = ``; | ||
let result = fixPrerenderInEmptyFile(source); | ||
|
||
expect(result).to.equal(expected); | ||
}); | ||
|
||
it('it works with self-closing tag', async function () { | ||
let source = ` | ||
<meta name="prerender-config" content="should-prerender" /> | ||
<meta name="other" content="should-prerender" />`; | ||
let expected = ` | ||
<meta name="prerender-config" content="skip" /> | ||
<meta name="other" content="should-prerender" />`; | ||
let result = fixPrerenderInEmptyFile(source); | ||
|
||
expect(result).to.equal(expected); | ||
}); | ||
|
||
it('it works with closing tag', async function () { | ||
let source = ` | ||
<meta name="prerender-config" content="should-prerender"></meta> | ||
<meta name="other" content="should-prerender"></meta>`; | ||
let expected = ` | ||
<meta name="prerender-config" content="skip"></meta> | ||
<meta name="other" content="should-prerender"></meta>`; | ||
let result = fixPrerenderInEmptyFile(source); | ||
|
||
expect(result).to.equal(expected); | ||
}); | ||
|
||
it('it works with only open tag', async function () { | ||
let source = ` | ||
<meta name="prerender-config" content="should-prerender"> | ||
<meta name="other" content="should-prerender">`; | ||
let expected = ` | ||
<meta name="prerender-config" content="skip"> | ||
<meta name="other" content="should-prerender">`; | ||
let result = fixPrerenderInEmptyFile(source); | ||
|
||
expect(result).to.equal(expected); | ||
}); | ||
}); |