Unverified Commit 4b6e9a45 authored by Amirali Esmaeili's avatar Amirali Esmaeili Committed by GitHub

Fix amphtml link rel not respecting basePath (#15949)

Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent d8edb2ea
...@@ -199,6 +199,10 @@ function assignDefaults(userConfig: { [key: string]: any }) { ...@@ -199,6 +199,10 @@ function assignDefaults(userConfig: { [key: string]: any }) {
if (result.assetPrefix === '') { if (result.assetPrefix === '') {
result.assetPrefix = result.basePath result.assetPrefix = result.basePath
} }
if (result.amp.canonicalBase === '') {
result.amp.canonicalBase = result.basePath
}
} }
} }
} }
......
export const config = { amp: 'hybrid' }
export default () => <p>Hello amp</p>
...@@ -1027,6 +1027,13 @@ describe('basePath development', () => { ...@@ -1027,6 +1027,13 @@ describe('basePath development', () => {
}) })
}) })
}) })
it('should respect basePath in amphtml link rel', async () => {
const html = await renderViaHTTP(context.appPort, '/docs/amp-hybrid')
const $ = cheerio.load(html)
const expectedAmpHtmlUrl = '/docs/amp-hybrid?amp=1'
expect($('link[rel=amphtml]').first().attr('href')).toBe(expectedAmpHtmlUrl)
})
}) })
describe('basePath production', () => { describe('basePath production', () => {
...@@ -1053,6 +1060,13 @@ describe('basePath production', () => { ...@@ -1053,6 +1060,13 @@ describe('basePath production', () => {
afterAll(() => stopApp(server)) afterAll(() => stopApp(server))
runTests(context) runTests(context)
it('should respect basePath in amphtml link rel', async () => {
const html = await renderViaHTTP(context.appPort, '/docs/amp-hybrid')
const $ = cheerio.load(html)
const expectedAmpHtmlUrl = '/docs/amp-hybrid.amp'
expect($('link[rel=amphtml]').first().attr('href')).toBe(expectedAmpHtmlUrl)
})
}) })
describe('basePath serverless', () => { describe('basePath serverless', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment