rsnext/packages/next/build/webpack/loaders/next-serverless-loader
Javi Velasco e65c56e7e6
Refactor i18n checks on request handling (#27328)
Currently there is a lot of mutation in the Next.js Server and the checks for Locale are directly coded in the general request handler. Ideally, we should have a function where we just pass the request input (url + headers + config) and generate a bunch of metadata that analyzes it generating all metadata we might require for both the URL and i18n + basePath information.

This PR brings:
- A new parsing function `parseUrl` that joins parsing an absolute/relative URL into a data structure compatible with the Node parsing output but missing redundant properties.
- A wrapper `parseNextURL` that extends `parseUrl` analyzing `i18n` and `basePath` based on the provided configuration, url and headers. This function is pure and stateless so it can be used outside of the Next.js context.
- Types improvements and reuse.
- Refactors `next-server.ts` request handling using the above mentioned functions so that the code there just apply effects to the `req` object and the `parsedUrl.query` leaving the code much more straightforward.
- Refactors `getRouteRegex` decomposing in two different functions where `getParametrizedRoute` can be used to retrieve the serializable data that is used to generate the Regex.
2021-07-21 16:12:33 +00:00
..
api-handler.ts Refactor decode failures (#26899) 2021-07-05 18:31:32 +02:00
index.ts Move next-server directory files to server directory (#26756) 2021-06-30 13:44:40 +02:00
page-handler.ts Refactor i18n checks on request handling (#27328) 2021-07-21 16:12:33 +00:00
utils.ts Fix forward slash encoding while interpolating (#26963) 2021-07-06 16:28:43 -05:00