Skip to content

Commit 5e55c3c

Browse files
Remove useless async declaration and replace regexp to plain string in AMP postProcessor (vercel#42495)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent fcfe914 commit 5e55c3c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/next/server/post-process.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ type middlewareSignature = {
2222
condition: ((options: postProcessOptions) => boolean) | null
2323
}
2424

25+
type PostProcessorFunction =
26+
| ((html: string) => Promise<string>)
27+
| ((html: string) => string)
28+
2529
const middlewareRegistry: Array<middlewareSignature> = []
2630

2731
function registerPostProcessor(
@@ -175,7 +179,7 @@ async function postProcessHTML(
175179
renderOpts: RenderOpts,
176180
{ inAmpMode, hybridAmp }: { inAmpMode: boolean; hybridAmp: boolean }
177181
) {
178-
const postProcessors: Array<(html: string) => Promise<string>> = [
182+
const postProcessors: Array<PostProcessorFunction> = [
179183
process.env.NEXT_RUNTIME !== 'edge' && inAmpMode
180184
? async (html: string) => {
181185
const optimizeAmp = require('./optimize-amp')
@@ -226,8 +230,8 @@ async function postProcessHTML(
226230
}
227231
: null,
228232
inAmpMode || hybridAmp
229-
? async (html: string) => {
230-
return html.replace(/&amp;amp=1/g, '&amp=1')
233+
? (html: string) => {
234+
return html.replaceAll('&amp;amp=1', '&amp=1')
231235
}
232236
: null,
233237
].filter(nonNullable)

0 commit comments

Comments
 (0)