Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update id handling for fonts #52559

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions packages/next/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ function getAmpPath(ampPath: string, asPath: string): string {
function getNextFontLinkTags(
nextFontManifest: NextFontManifest | undefined,
dangerousAsPath: string,
assetPrefix: string = '',
assetQueryString: string = ''
assetPrefix: string = ''
) {
if (!nextFontManifest) {
return {
Expand All @@ -378,11 +377,6 @@ function getNextFontLinkTags(
(appFontsEntry || pageFontsEntry)
)

// we only add if the dpl query is present for fonts
if (!assetQueryString.includes('dpl=')) {
assetQueryString = ''
}

return {
preconnect: preconnectToSelf ? (
<link
Expand All @@ -401,9 +395,7 @@ function getNextFontLinkTags(
<link
key={fontFile}
rel="preload"
href={`${assetPrefix}/_next/${encodeURI(
fontFile
)}${assetQueryString}`}
href={`${assetPrefix}/_next/${encodeURI(fontFile)}`}
as="font"
type={`font/${ext}`}
crossOrigin="anonymous"
Expand Down Expand Up @@ -800,8 +792,7 @@ export class Head extends React.Component<HeadProps> {
const nextFontLinkTags = getNextFontLinkTags(
nextFontManifest,
dangerousAsPath,
assetPrefix,
this.context.assetQueryString
assetPrefix
)

return (
Expand Down
4 changes: 1 addition & 3 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,7 @@ export async function renderToHTMLOrFlight(
const fontFilename = preloadedFontFiles[i]
const ext = /\.(woff|woff2|eot|ttf|otf)$/.exec(fontFilename)![1]
const type = `font/${ext}`
const href = `${assetPrefix}/_next/${fontFilename}${getAssetQueryString(
false
)}`
const href = `${assetPrefix}/_next/${fontFilename}`
ComponentMod.preloadFont(href, type)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ createNextDescribe(

for (const link of links) {
if (link.attribs.href) {
expect(link.attribs.href).toContain('dpl=' + deploymentId)
if (link.attribs.as === 'font') {
expect(link.attribs.href).not.toContain('dpl=' + deploymentId)
} else {
expect(link.attribs.href).toContain('dpl=' + deploymentId)
}
}
}

Expand Down