Unverified Commit fab164dc authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update id handling for fonts (#52559)

We don't need to apply the ID here as these assets should always be available across deploys. 

x-ref: [slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1689035592272659)
parent 56fcd7ac
...@@ -354,8 +354,7 @@ function getAmpPath(ampPath: string, asPath: string): string { ...@@ -354,8 +354,7 @@ function getAmpPath(ampPath: string, asPath: string): string {
function getNextFontLinkTags( function getNextFontLinkTags(
nextFontManifest: NextFontManifest | undefined, nextFontManifest: NextFontManifest | undefined,
dangerousAsPath: string, dangerousAsPath: string,
assetPrefix: string = '', assetPrefix: string = ''
assetQueryString: string = ''
) { ) {
if (!nextFontManifest) { if (!nextFontManifest) {
return { return {
...@@ -378,11 +377,6 @@ function getNextFontLinkTags( ...@@ -378,11 +377,6 @@ function getNextFontLinkTags(
(appFontsEntry || pageFontsEntry) (appFontsEntry || pageFontsEntry)
) )
// we only add if the dpl query is present for fonts
if (!assetQueryString.includes('dpl=')) {
assetQueryString = ''
}
return { return {
preconnect: preconnectToSelf ? ( preconnect: preconnectToSelf ? (
<link <link
...@@ -401,9 +395,7 @@ function getNextFontLinkTags( ...@@ -401,9 +395,7 @@ function getNextFontLinkTags(
<link <link
key={fontFile} key={fontFile}
rel="preload" rel="preload"
href={`${assetPrefix}/_next/${encodeURI( href={`${assetPrefix}/_next/${encodeURI(fontFile)}`}
fontFile
)}${assetQueryString}`}
as="font" as="font"
type={`font/${ext}`} type={`font/${ext}`}
crossOrigin="anonymous" crossOrigin="anonymous"
...@@ -800,8 +792,7 @@ export class Head extends React.Component<HeadProps> { ...@@ -800,8 +792,7 @@ export class Head extends React.Component<HeadProps> {
const nextFontLinkTags = getNextFontLinkTags( const nextFontLinkTags = getNextFontLinkTags(
nextFontManifest, nextFontManifest,
dangerousAsPath, dangerousAsPath,
assetPrefix, assetPrefix
this.context.assetQueryString
) )
return ( return (
......
...@@ -466,9 +466,7 @@ export async function renderToHTMLOrFlight( ...@@ -466,9 +466,7 @@ export async function renderToHTMLOrFlight(
const fontFilename = preloadedFontFiles[i] const fontFilename = preloadedFontFiles[i]
const ext = /\.(woff|woff2|eot|ttf|otf)$/.exec(fontFilename)![1] const ext = /\.(woff|woff2|eot|ttf|otf)$/.exec(fontFilename)![1]
const type = `font/${ext}` const type = `font/${ext}`
const href = `${assetPrefix}/_next/${fontFilename}${getAssetQueryString( const href = `${assetPrefix}/_next/${fontFilename}`
false
)}`
ComponentMod.preloadFont(href, type) ComponentMod.preloadFont(href, type)
} }
} else { } else {
......
...@@ -39,9 +39,13 @@ createNextDescribe( ...@@ -39,9 +39,13 @@ createNextDescribe(
for (const link of links) { for (const link of links) {
if (link.attribs.href) { if (link.attribs.href) {
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)
} }
} }
}
const browser = await next.browser(urlPath) const browser = await next.browser(urlPath)
const requests = [] const requests = []
......
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