Skip to content

Commit 27d78a5

Browse files
RobVermeerijjk
andauthoredJun 22, 2021
Fix domain locales not available on client (#26083)
* bug: Fix domain locales not available on client * Add test case * update tests Co-authored-by: JJ Kasper <jj@jjsweb.site>
1 parent 005a6e4 commit 27d78a5

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed
 

‎packages/next/client/router.ts

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const urlPropertyFields = [
4343
'isReady',
4444
'isPreview',
4545
'isLocaleDomain',
46+
'domainLocales',
4647
]
4748
const routerEvents = [
4849
'routeChangeStart',

‎test/integration/build-output/test/index.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ describe('Build Output', () => {
129129
expect(parseFloat(err404Size)).toBeCloseTo(gz ? 3.17 : 8.51, 1)
130130
expect(err404Size.endsWith('kB')).toBe(true)
131131

132-
expect(parseFloat(err404FirstLoad)).toBeCloseTo(gz ? 66.9 : 204, 1)
132+
expect(parseFloat(err404FirstLoad)).toBeCloseTo(gz ? 66.9 : 205, 1)
133133
expect(err404FirstLoad.endsWith('kB')).toBe(true)
134134

135135
expect(parseFloat(sharedByAll)).toBeCloseTo(gz ? 63.7 : 196, 1)

‎test/integration/i18n-support-base-path/pages/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default function Page(props) {
1111
<p id="router-locale">{router.locale}</p>
1212
<p id="router-default-locale">{router.defaultLocale}</p>
1313
<p id="router-locales">{JSON.stringify(router.locales)}</p>
14+
<p id="router-domain-locales">{JSON.stringify(router.domainLocales)}</p>
1415
<p id="router-query">{JSON.stringify(router.query)}</p>
1516
<p id="router-pathname">{router.pathname}</p>
1617
<p id="router-as-path">{router.asPath}</p>

‎test/integration/i18n-support/pages/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default function Page(props) {
1111
<p id="router-locale">{router.locale}</p>
1212
<p id="router-default-locale">{router.defaultLocale}</p>
1313
<p id="router-locales">{JSON.stringify(router.locales)}</p>
14+
<p id="router-domain-locales">{JSON.stringify(router.domainLocales)}</p>
1415
<p id="router-query">{JSON.stringify(router.query)}</p>
1516
<p id="router-pathname">{router.pathname}</p>
1617
<p id="router-as-path">{router.asPath}</p>

‎test/integration/i18n-support/test/shared.js

+15
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ async function addDefaultLocaleCookie(browser) {
3737
}
3838

3939
export function runTests(ctx) {
40+
it.only('should have domainLocales available on useRouter', async () => {
41+
const browser = await webdriver(ctx.appPort, `${ctx.basePath || '/'}`)
42+
expect(
43+
JSON.parse(await browser.elementByCss('#router-domain-locales').text())
44+
).toEqual([
45+
{
46+
http: true,
47+
domain: 'example.do',
48+
defaultLocale: 'do',
49+
locales: ['do-BE'],
50+
},
51+
{ domain: 'example.com', defaultLocale: 'go', locales: ['go-BE'] },
52+
])
53+
})
54+
4055
it('should not error with similar named cookie to locale cookie', async () => {
4156
const res = await fetchViaHTTP(
4257
ctx.appPort,

0 commit comments

Comments
 (0)
Please sign in to comment.