提交 75a2c45f 编写于 作者: J JJ Kasper 提交者: Tim Neutkens

AMP fix escaped rel (#7045)

if `&amp=1` is used to point to the `amphtml` version of a page it get's escaped causing it to become `&amp=1` this fixes it to stay as `&amp=1`

Closes: #7038 
上级 59b328b5
......@@ -450,6 +450,11 @@ export async function renderToHTML(
await renderOpts.ampValidator(html, pathname)
}
}
if (amphtml || hasAmp) {
// fix &amp being escaped for amphtml rel link
html = html.replace(/&amp=1/g, '&amp=1')
}
return html
}
......
......@@ -152,6 +152,11 @@ describe('AMP Usage', () => {
).toBe('/use-amp-hook?amp=1')
})
it('should render link rel amphtml with existing query', async () => {
const html = await renderViaHTTP(appPort, '/use-amp-hook?hello=1')
expect(html).not.toMatch(/&amp=1/)
})
it('should render the AMP page that uses the AMP hook', async () => {
const html = await renderViaHTTP(appPort, '/use-amp-hook?amp=1')
const $ = cheerio.load(html)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册