Skip to content

Commit

Permalink
fix: strip public prefix correctly on the client (#1065)
Browse files Browse the repository at this point in the history
Co-authored-by: Isaac Hinman <isaac@isaachinman.com>
  • Loading branch information
skrivanos and isaachinman authored Mar 15, 2021
1 parent a688ed6 commit ff9b5fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/config/createConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ describe('createConfig', () => {
it('returns a valid config when only lng is provided', () => {
const config = createConfig({ lng: 'en' } as UserConfig)

expect((config.backend as any).addPath).toMatch('/public/locales/{{lng}}/{{ns}}.missing.json')
expect((config.backend as any).loadPath).toMatch('/public/locales/{{lng}}/{{ns}}.json')
expect((config.backend as any).addPath).toMatch('/locales/{{lng}}/{{ns}}.missing.json')
expect((config.backend as any).loadPath).toMatch('/locales/{{lng}}/{{ns}}.json')
expect(config.defaultLocale).toEqual('en')
expect(config.defaultNS).toEqual('common')
expect(config.errorStackTraceLimit).toEqual(0)
Expand All @@ -175,7 +175,7 @@ describe('createConfig', () => {
lng: 'en',
} as UserConfig)
expect((config.backend as any).hello).toEqual('world')
expect((config.backend as any).loadPath).toMatch('/public/locales/{{lng}}/{{ns}}.json')
expect((config.backend as any).loadPath).toMatch('/locales/{{lng}}/{{ns}}.json')
})
})
})
4 changes: 2 additions & 2 deletions src/config/createConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export const createConfig = (userConfig: UserConfig): InternalConfig => {
//
// Remove public prefix from client site config
//
if (localePath.startsWith('/public/')) {
clientLocalePath = localePath.replace(/^\/public/, '')
if (localePath.match(/^\.?\/public\//)) {
clientLocalePath = localePath.replace(/^\.?\/public/, '')
}

//
Expand Down

1 comment on commit ff9b5fa

@vercel
Copy link

@vercel vercel bot commented on ff9b5fa Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.