Skip to content

Commit

Permalink
Remove useless async declaration and replace regexp to plain string i…
Browse files Browse the repository at this point in the history
…n AMP postProcessor (#42495)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
NOCELL and kodiakhq[bot] committed Nov 9, 2022
1 parent fcfe914 commit 5e55c3c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/next/server/post-process.ts
Expand Up @@ -22,6 +22,10 @@ type middlewareSignature = {
condition: ((options: postProcessOptions) => boolean) | null
}

type PostProcessorFunction =
| ((html: string) => Promise<string>)
| ((html: string) => string)

const middlewareRegistry: Array<middlewareSignature> = []

function registerPostProcessor(
Expand Down Expand Up @@ -175,7 +179,7 @@ async function postProcessHTML(
renderOpts: RenderOpts,
{ inAmpMode, hybridAmp }: { inAmpMode: boolean; hybridAmp: boolean }
) {
const postProcessors: Array<(html: string) => Promise<string>> = [
const postProcessors: Array<PostProcessorFunction> = [
process.env.NEXT_RUNTIME !== 'edge' && inAmpMode
? async (html: string) => {
const optimizeAmp = require('./optimize-amp')
Expand Down Expand Up @@ -226,8 +230,8 @@ async function postProcessHTML(
}
: null,
inAmpMode || hybridAmp
? async (html: string) => {
return html.replace(/&amp;amp=1/g, '&amp=1')
? (html: string) => {
return html.replaceAll('&amp;amp=1', '&amp=1')
}
: null,
].filter(nonNullable)
Expand Down

0 comments on commit 5e55c3c

Please sign in to comment.