Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit d9417b8

Browse files
committed
Merge branch 'feature/incremental-static-regeneration' of https://github.com/serverless-nextjs/serverless-next.js into feature/incremental-static-regeneration
2 parents 41202f3 + 09f739f commit d9417b8

File tree

13 files changed

+75
-21
lines changed

13 files changed

+75
-21
lines changed

packages/libs/core/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
# 1.0.0-alpha.2 (2021-05-05)
7+
8+
### Bug Fixes
9+
10+
- **core:** extend locale matching to secondary languages ([#1040](https://github.com/serverless-nextjs/serverless-next.js/issues/1040)) ([a2c476c](https://github.com/serverless-nextjs/serverless-next.js/commit/a2c476cb923b3a2a382541c7ff9327c0861bfd1c))

packages/libs/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sls-next/core",
3-
"version": "1.0.0-alpha.1",
3+
"version": "1.0.0-alpha.2",
44
"description": "Handles Next.js routing independent of provider",
55
"publishConfig": {
66
"access": "public"

packages/libs/core/src/locale.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,23 @@ export const getAcceptLanguageLocale = (
3737
routesManifest: RoutesManifest
3838
) => {
3939
if (routesManifest.i18n) {
40-
const locales = routesManifest.i18n.locales;
4140
const defaultLocale = routesManifest.i18n.defaultLocale;
41+
const locales = new Set(
42+
routesManifest.i18n.locales.map((locale) => locale.toLowerCase())
43+
);
4244

43-
const preferredLanguage = Accept.language(acceptLanguage).toLowerCase();
44-
45-
// Find language in locale that matches preferred language
46-
for (const locale of locales) {
47-
if (preferredLanguage === locale.toLowerCase()) {
48-
if (locale !== defaultLocale) {
49-
return `${routesManifest.basePath}/${locale}${
50-
manifest.trailingSlash ? "/" : ""
51-
}`;
52-
}
45+
// Accept.language(header, locales) prefers the locales order,
46+
// so we ask for all to find the order preferred by user.
47+
for (const language of Accept.languages(acceptLanguage)) {
48+
const locale = language.toLowerCase();
49+
if (locale === defaultLocale) {
5350
break;
5451
}
52+
if (locales.has(locale)) {
53+
return `${routesManifest.basePath}/${locale}${
54+
manifest.trailingSlash ? "/" : ""
55+
}`;
56+
}
5557
}
5658
}
5759
};

packages/libs/core/tests/locale.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ describe("Locale Utils Tests", () => {
4747
});
4848

4949
it.each`
50-
acceptLang | expectedPath
51-
${"fr"} | ${"/fr/"}
52-
${"nl"} | ${"/nl/"}
50+
acceptLang | expectedPath
51+
${"fr"} | ${"/fr/"}
52+
${"nl"} | ${"/nl/"}
53+
${"de, fr"} | ${"/fr/"}
54+
${"fr;q=0.7, nl;q=0.9"} | ${"/nl/"}
5355
`(
5456
"returns $expectedPath for $acceptLang",
5557
({ acceptLang, expectedPath }) => {
@@ -66,7 +68,7 @@ describe("Locale Utils Tests", () => {
6668
it.each`
6769
acceptLang
6870
${"en"}
69-
${"en-Uk"}
71+
${"nl;q=0.7, en;q=0.9"}
7072
`("returns nothing for $acceptLang", ({ acceptLang }) => {
7173
const newPath = getAcceptLanguageLocale(
7274
acceptLang,

packages/libs/lambda-at-edge/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.8.1-alpha.2](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-05)
7+
8+
**Note:** Version bump only for package @sls-next/lambda-at-edge
9+
10+
## [1.8.1-alpha.1](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-05)
11+
12+
**Note:** Version bump only for package @sls-next/lambda-at-edge
13+
14+
## [1.8.1-alpha.0](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-05)
15+
16+
### Bug Fixes
17+
18+
- **core:** extend locale matching to secondary languages ([#1040](https://github.com/serverless-nextjs/serverless-next.js/issues/1040)) ([a2c476c](https://github.com/serverless-nextjs/serverless-next.js/commit/a2c476cb923b3a2a382541c7ff9327c0861bfd1c))
19+
620
# [1.8.0](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-03)
721

822
**Note:** Version bump only for package @sls-next/lambda-at-edge

packages/libs/lambda-at-edge/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publishConfig": {
44
"access": "public"
55
},
6-
"version": "1.8.0",
6+
"version": "1.8.1-alpha.2",
77
"description": "Provides handlers that can be used in CloudFront Lambda@Edge to deploy next.js applications to the edge",
88
"main": "dist/index.js",
99
"types": "dist/index.d.ts",

packages/libs/lambda-at-edge/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const generateConfig = (input) => ({
3030
json(),
3131
commonjs(),
3232
externals({
33-
exclude: "@sls-next/next-aws-cloudfront"
33+
exclude: ["@sls-next/next-aws-cloudfront", "@sls-next/core"]
3434
}),
3535
nodeResolve(),
3636
typescript({

packages/libs/lambda-at-edge/src/default-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const router = (
157157
return html.nonDynamic[normalisedUri];
158158
}
159159

160-
// dynamic routes are matched first
160+
// Dynamic routes are matched first
161161
for (const route in allDynamicRoutes) {
162162
const { file, regex } = allDynamicRoutes[route];
163163

packages/libs/lambda-at-edge/tests/default-handler/default-handler-with-locales.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,8 @@ describe("Lambda@Edge", () => {
974974
${"fr,nl,en"} | ${"/fr"}
975975
${"nl,fr"} | ${"/nl"}
976976
${"fr,nl"} | ${"/fr"}
977+
${"de,nl"} | ${"/nl"}
978+
${"fr;q=0.5,de;q=0.8"} | ${"/fr"}
977979
${"en;q=0.5,nl;q=0.8"} | ${"/nl"}
978980
`(
979981
"redirects path / with accept-language [$acceptLanguageHeader] to $expectedRedirect",

packages/serverless-components/nextjs-cdk-construct/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.19.1-alpha.2](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-05)
7+
8+
**Note:** Version bump only for package @sls-next/cdk-construct
9+
10+
## [1.19.1-alpha.1](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-05)
11+
12+
**Note:** Version bump only for package @sls-next/cdk-construct
13+
14+
## [1.19.1-alpha.0](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-05)
15+
16+
**Note:** Version bump only for package @sls-next/cdk-construct
17+
618
# [1.19.0](https://github.com/serverless-nextjs/serverless-next.js/compare/@sls-next/[email protected]...@sls-next/[email protected]) (2021-05-03)
719

820
**Note:** Version bump only for package @sls-next/cdk-construct

0 commit comments

Comments
 (0)