mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
fix: capitalize filter not lower case trailing string, fixes #326
This commit is contained in:
@@ -54,7 +54,7 @@ export function stripNewlines (v: string) {
|
||||
|
||||
export function capitalize (str: string) {
|
||||
str = stringify(str)
|
||||
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()
|
||||
}
|
||||
|
||||
export function replace (v: string, pattern: string, replacement: string) {
|
||||
|
||||
@@ -33,6 +33,9 @@ describe('filters/string', function () {
|
||||
it('should capitalize first', () => test('{{ "i am good" | capitalize }}', 'I am good'))
|
||||
it('should return empty for nil', () => test('{{ nil | capitalize }}', ''))
|
||||
it('should return empty for undefined', async () => test('{{ foo | capitalize }}', ''))
|
||||
it('should capitalize only first word', async () => test('{{"foo bar" | capitalize}}', 'Foo bar'))
|
||||
it('should to lower case if prefixed by spaces', async () => test('{{" foo BaR" | capitalize}}', ' foo bar'))
|
||||
it('should to lower case trailing words', async () => test('{{"foo BaR" | capitalize}}', 'Foo bar'))
|
||||
})
|
||||
describe('concat', function () {
|
||||
it('should concat arrays', () => test(`
|
||||
|
||||
Reference in New Issue
Block a user