From cb0249bf53e360d8d60d67eb68d78a7ba827ef14 Mon Sep 17 00:00:00 2001 From: Jan Stevens Date: Fri, 21 Jun 2024 13:55:58 +0200 Subject: [PATCH] fix: eslint issues --- packages/open-next/src/core/routingHandler.ts | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/open-next/src/core/routingHandler.ts b/packages/open-next/src/core/routingHandler.ts index 5a35496d..46683f1c 100644 --- a/packages/open-next/src/core/routingHandler.ts +++ b/packages/open-next/src/core/routingHandler.ts @@ -30,7 +30,11 @@ const dynamicRegexp = RoutesManifest.routes.dynamic.map( (route) => new RegExp(route.regex), ); -const localeRegexp = RoutesManifest.locales.length ? new RegExp(RoutesManifest.locales.map((locale) => `(^/${locale}?/)`).join("|")) : null; +const localeRegexp = RoutesManifest.locales.length + ? new RegExp( + RoutesManifest.locales.map((locale) => `(^/${locale}?/)`).join("|"), + ) + : null; export default async function routingHandler( event: InternalEvent, @@ -72,9 +76,7 @@ export default async function routingHandler( let normalizedRawPath = internalEvent.rawPath.replace(localeRegexp, "/"); const isStaticRoute = !isExternalRewrite && - staticRegexp.some((route) => - route.test(normalizedRawPath), - ); + staticRegexp.some((route) => route.test(normalizedRawPath)); if (!isStaticRoute && !isExternalRewrite) { // Second rewrite to be applied @@ -92,9 +94,7 @@ export default async function routingHandler( const isDynamicRoute = !isExternalRewrite && - dynamicRegexp.some((route) => - route.test(normalizedRawPath), - ); + dynamicRegexp.some((route) => route.test(normalizedRawPath)); if (!isDynamicRoute && !isStaticRoute && !isExternalRewrite) { // Fallback rewrite to be applied const fallbackRewrites = handleRewrites( @@ -114,7 +114,7 @@ export default async function routingHandler( const isRouteFoundBeforeAllRewrites = isStaticRoute || isDynamicRoute || isExternalRewrite; - + normalizedRawPath = internalEvent.rawPath.replace(localeRegexp, "/"); // If we still haven't found a route, we show the 404 page @@ -123,12 +123,8 @@ export default async function routingHandler( !isRouteFoundBeforeAllRewrites && !isApiRoute && // We need to check again once all rewrites have been applied - !staticRegexp.some((route) => - route.test(normalizedRawPath), - ) && - !dynamicRegexp.some((route) => - route.test(normalizedRawPath), - ) + !staticRegexp.some((route) => route.test(normalizedRawPath)) && + !dynamicRegexp.some((route) => route.test(normalizedRawPath)) ) { internalEvent = { ...internalEvent,