@@ -85,7 +85,7 @@ describe("route overrides", () => {
8585 assert . deepStrictEqual ( updatedManifest , expectedManifest ) ;
8686 } ) ;
8787
88- it ( "should add middleware header when middleware exists " , async ( ) => {
88+ it ( "should add middleware header only to routes for which middleware is enabled " , async ( ) => {
8989 const { addRouteOverrides } = await importOverrides ;
9090 const initialManifest : RoutesManifest = {
9191 version : 3 ,
@@ -109,8 +109,8 @@ describe("route overrides", () => {
109109 page : "/" ,
110110 matchers : [
111111 {
112- regexp : "^/.*$ " ,
113- originalSource : "/:path* " ,
112+ regexp : "/hello " ,
113+ originalSource : "/hello " ,
114114 } ,
115115 ] ,
116116 } ,
@@ -150,9 +150,13 @@ describe("route overrides", () => {
150150 key : "x-fah-adapter" ,
151151 value : "nextjs-1.0.0" ,
152152 } ,
153- { key : "x-fah-middleware" , value : "true" } ,
154153 ] ,
155154 } ,
155+ {
156+ source : "/hello" ,
157+ regex : "/hello" ,
158+ headers : [ { key : "x-fah-middleware" , value : "true" } ] ,
159+ } ,
156160 ] ,
157161 } ;
158162
@@ -172,13 +176,13 @@ describe("next config overrides", () => {
172176 ...config,
173177 images: {
174178 ...(config.images || {}),
175- ...(config.images?.unoptimized === undefined && config.images?.loader === undefined
176- ? { unoptimized: true }
179+ ...(config.images?.unoptimized === undefined && config.images?.loader === undefined
180+ ? { unoptimized: true }
177181 : {}),
178182 },
179183 });
180184
181- const config = typeof originalConfig === 'function'
185+ const config = typeof originalConfig === 'function'
182186 ? async (...args) => {
183187 const resolvedConfig = await originalConfig(...args);
184188 return fahOptimizedConfig(resolvedConfig);
@@ -194,12 +198,12 @@ describe("next config overrides", () => {
194198 const { overrideNextConfig } = await importOverrides ;
195199 const originalConfig = `
196200 // @ts-check
197-
201+
198202 /** @type {import('next').NextConfig} */
199203 const nextConfig = {
200204 /* config options here */
201205 }
202-
206+
203207 module.exports = nextConfig
204208 ` ;
205209
@@ -213,7 +217,7 @@ describe("next config overrides", () => {
213217 normalizeWhitespace ( `
214218 // @ts-nocheck
215219 const originalConfig = require('./next.config.original.js');
216-
220+
217221 ${ nextConfigOverrideBody }
218222
219223 module.exports = config;
@@ -225,14 +229,14 @@ describe("next config overrides", () => {
225229 const { overrideNextConfig } = await importOverrides ;
226230 const originalConfig = `
227231 // @ts-check
228-
232+
229233 /**
230234 * @type {import('next').NextConfig}
231235 */
232236 const nextConfig = {
233237 /* config options here */
234238 }
235-
239+
236240 export default nextConfig
237241 ` ;
238242
@@ -257,7 +261,7 @@ describe("next config overrides", () => {
257261 const { overrideNextConfig } = await importOverrides ;
258262 const originalConfig = `
259263 // @ts-check
260-
264+
261265 export default (phase, { defaultConfig }) => {
262266 /**
263267 * @type {import('next').NextConfig}
@@ -280,7 +284,7 @@ describe("next config overrides", () => {
280284 import originalConfig from './next.config.original.mjs';
281285
282286 ${ nextConfigOverrideBody }
283-
287+
284288 export default config;
285289 ` ) ,
286290 ) ;
@@ -290,11 +294,11 @@ describe("next config overrides", () => {
290294 const { overrideNextConfig } = await importOverrides ;
291295 const originalConfig = `
292296 import type { NextConfig } from 'next'
293-
297+
294298 const nextConfig: NextConfig = {
295299 /* config options here */
296300 }
297-
301+
298302 export default nextConfig
299303 ` ;
300304
@@ -307,9 +311,9 @@ describe("next config overrides", () => {
307311 normalizeWhitespace ( `
308312 // @ts-nocheck
309313 import originalConfig from './next.config.original';
310-
314+
311315 ${ nextConfigOverrideBody }
312-
316+
313317 module.exports = config;
314318 ` ) ,
315319 ) ;
0 commit comments