Skip to content

Commit

Permalink
review fixes + don't recurse if split length is 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Linderoth committed Jun 28, 2021
1 parent 0529560 commit 816f1e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const parseLocale = (preset, object, isLocal) => {
l = presetLower
}
const presetSplit = preset.split('-')
if (!l && presetSplit.length) {
if (!l && presetSplit.length > 1) {
return parseLocale(presetSplit[0])
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions test/plugin/localizedFormat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ it('Uses the localized lowercase formats if defined', () => {
})

it('Uses fallback to xx if xx-yy not available', () => {
expect(dayjs('2019-02-01').locale('es-yy').format('L'))
.toBe('01/02/2019')
expect(dayjs('2019-02-01').locale('en-yy').format('MMMM'))
.toBe('February')
})

it('Uses xx-yy if xx-YY is provided', () => {
expect(dayjs('2019-02-01').locale('es-US').format('L'))
.toBe('01/02/2019')
expect(dayjs('2019-02-01').locale('es-US').format('MMMM'))
.toBe('febrero')
})

it('Uses the localized uppercase formats as a base for lowercase formats, if not defined', () => {
Expand Down

0 comments on commit 816f1e8

Please sign in to comment.