Unverified Commit 91e5b6b8 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

Backport "fix: add `?dpl` to fonts in `/_next/static/media` (#82384)" (#82421)

Backports #82384
Co-authored-by: 's avatarSteven <steven@ceriously.com>
parent f1629d93
......@@ -363,7 +363,8 @@ function getAmpPath(ampPath: string, asPath: string): string {
function getNextFontLinkTags(
nextFontManifest: DeepReadonly<NextFontManifest> | undefined,
dangerousAsPath: string,
assetPrefix: string = ''
assetPrefix: string = '',
assetQueryString: string = ''
) {
if (!nextFontManifest) {
return {
......@@ -403,7 +404,7 @@ function getNextFontLinkTags(
<link
key={fontFile}
rel="preload"
href={`${assetPrefix}/_next/${encodeURIPath(fontFile)}`}
href={`${assetPrefix}/_next/${encodeURIPath(fontFile)}${assetQueryString}`}
as="font"
type={`font/${ext}`}
crossOrigin="anonymous"
......@@ -765,7 +766,8 @@ export class Head extends React.Component<HeadProps> {
const nextFontLinkTags = getNextFontLinkTags(
nextFontManifest,
dangerousAsPath,
assetPrefix
assetPrefix,
this.context.assetQueryString
)
const tracingMetadata = getTracedMetadata(
......
......@@ -46,7 +46,7 @@ export function getLayerAssets({
const fontFilename = preloadedFontFiles[i]
const ext = /\.(woff|woff2|eot|ttf|otf)$/.exec(fontFilename)![1]
const type = `font/${ext}`
const href = `${ctx.assetPrefix}/_next/${encodeURIPath(fontFilename)}`
const href = `${ctx.assetPrefix}/_next/${encodeURIPath(fontFilename)}${getAssetQueryString(ctx, false)}`
preloadCallbacks.push(() => {
ctx.componentMod.preloadFont(
......
......@@ -45,11 +45,7 @@ describe('deployment-id-handling disabled', () => {
for (const link of links) {
if (link.attribs.href) {
if (link.attribs.as === 'font') {
expect(link.attribs.href).not.toContain('dpl=' + deploymentId)
} else {
expect(link.attribs.href).not.toContain('dpl=' + deploymentId)
}
expect(link.attribs.href).not.toContain('dpl=' + deploymentId)
}
}
......
......@@ -39,11 +39,7 @@ describe.each(['NEXT_DEPLOYMENT_ID', 'CUSTOM_DEPLOYMENT_ID'])(
for (const link of links) {
if (link.attribs.href && link.attribs.rel !== 'expect') {
if (link.attribs.as === 'font') {
expect(link.attribs.href).not.toContain('dpl=' + deploymentId)
} else {
expect(link.attribs.href).toContain('dpl=' + deploymentId)
}
expect(link.attribs.href).toContain('dpl=' + deploymentId)
}
}
......@@ -173,11 +169,7 @@ describe('deployment-id-handling disabled', () => {
for (const link of links) {
if (link.attribs.href) {
if (link.attribs.as === 'font') {
expect(link.attribs.href).not.toContain('dpl=' + deploymentId)
} else {
expect(link.attribs.href).not.toContain('dpl=' + deploymentId)
}
expect(link.attribs.href).not.toContain('dpl=' + deploymentId)
}
}
......
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