Skip to content

Commit

Permalink
chore: refactor detectedLocale assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
orinokai committed Jun 17, 2024
1 parent ff7f82e commit 13a8cce
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions edge-runtime/lib/next-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,11 @@ const normalizeRequestURL = (
nextConfig?: RequestData['nextConfig'],
): { url: string; detectedLocale?: string } => {
const url = new URL(originalURL)
let detectedLocale: string | undefined

let pathname = removeBasePath(url.pathname, nextConfig?.basePath)

// If the i18n config is present, remove the locale from the URL and store it
if (nextConfig?.i18n) {
;({ detectedLocale } = normalizeLocalePath(pathname, nextConfig?.i18n?.locales))
}
// If it exists, remove the locale from the URL and store it
const { detectedLocale } = normalizeLocalePath(pathname, nextConfig?.i18n?.locales)

if (!nextConfig?.skipMiddlewareUrlNormalize) {
// We want to run middleware for data requests and expose the URL of the
Expand Down

0 comments on commit 13a8cce

Please sign in to comment.