Skip to content

Commit

Permalink
Merge branch 'main' into streamline-e2e-report
Browse files Browse the repository at this point in the history
  • Loading branch information
eladroz committed Jun 23, 2024
2 parents 8e6894e + 5ea7ab6 commit da9e7b7
Show file tree
Hide file tree
Showing 25 changed files with 2,003 additions and 1,306 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "5.3.2"
".": "5.3.3"
}
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [5.3.3](https://github.com/netlify/next-runtime/compare/v5.3.2...v5.3.3) (2024-06-18)


### Bug Fixes

* middleware i18n normalization ([#2483](https://github.com/netlify/next-runtime/issues/2483)) ([a9efa9c](https://github.com/netlify/next-runtime/commit/a9efa9c91f3796760ed8acdf0d3340dbe66ea329))
* set systemlogger debug log level for debug requests ([#571](https://github.com/netlify/next-runtime/issues/571)) ([a6d09f3](https://github.com/netlify/next-runtime/commit/a6d09f3994bffdb40ef3bf3e5882e9195c1fff4a))
* update cache handler to accomodate changes in next@canary ([#2480](https://github.com/netlify/next-runtime/issues/2480)) ([f4eeaa2](https://github.com/netlify/next-runtime/commit/f4eeaa2eb41180409b41fcd44e0c2ebc05025a49))
* update in-memory prerender manifest with information from full route cache ([#579](https://github.com/netlify/next-runtime/issues/579)) ([c91e257](https://github.com/netlify/next-runtime/commit/c91e2575dd5b5faee6d9cb67f92def5171462015))

## [5.3.2](https://github.com/netlify/next-runtime/compare/v5.3.1...v5.3.2) (2024-05-28)

### Bug Fixes
Expand Down
9 changes: 5 additions & 4 deletions e2e-report/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e-report/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@netlify/plugin-nextjs": "^5.3.2",
"@netlify/plugin-nextjs": "^5.3.3",
"next": "^14.2.3",
"react": "^18.3.1",
"react-dom": "^18.3.1"
Expand Down
40 changes: 14 additions & 26 deletions edge-runtime/lib/next-request.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import type { Context } from '@netlify/edge-functions'

import { addBasePath, normalizeDataUrl, normalizeLocalePath, removeBasePath } from './util.ts'
import {
addBasePath,
addTrailingSlash,
normalizeDataUrl,
normalizeLocalePath,
removeBasePath,
} from './util.ts'

interface I18NConfig {
defaultLocale: string
Expand Down Expand Up @@ -41,43 +47,25 @@ const normalizeRequestURL = (
): { url: string; detectedLocale?: string } => {
const url = new URL(originalURL)

url.pathname = removeBasePath(url.pathname, nextConfig?.basePath)
const didRemoveBasePath = url.toString() !== originalURL
let pathname = removeBasePath(url.pathname, nextConfig?.basePath)

let detectedLocale: string | undefined

if (nextConfig?.i18n) {
const { pathname, detectedLocale: detected } = normalizeLocalePath(
url.pathname,
nextConfig?.i18n?.locales,
)
if (!nextConfig?.skipMiddlewareUrlNormalize) {
url.pathname = pathname || '/'
}
detectedLocale = detected
}
// 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
// corresponding pages, so we have to normalize the URLs before running
// the handler.
url.pathname = normalizeDataUrl(url.pathname)
pathname = normalizeDataUrl(pathname)

// Normalizing the trailing slash based on the `trailingSlash` configuration
// property from the Next.js config.
if (nextConfig?.trailingSlash && url.pathname !== '/' && !url.pathname.endsWith('/')) {
url.pathname = `${url.pathname}/`
if (nextConfig?.trailingSlash) {
pathname = addTrailingSlash(pathname)
}
}

if (didRemoveBasePath) {
url.pathname = addBasePath(url.pathname, nextConfig?.basePath)
}

// keep the locale in the url for request.nextUrl object
if (detectedLocale) {
url.pathname = `/${detectedLocale}${url.pathname}`
}
url.pathname = addBasePath(pathname, nextConfig?.basePath)

return {
url: url.toString(),
Expand Down
Loading

0 comments on commit da9e7b7

Please sign in to comment.