mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
feature: url_decode, working on #94
This commit is contained in:
+2
-1
@@ -94,7 +94,8 @@ const filters = {
|
||||
})
|
||||
},
|
||||
'upcase': str => stringify(str).toUpperCase(),
|
||||
'url_encode': encodeURIComponent
|
||||
'url_decode': x => x.split('+').map(decodeURIComponent).join(' '),
|
||||
'url_encode': x => x.split(' ').map(encodeURIComponent).join('+')
|
||||
}
|
||||
|
||||
function escape (str) {
|
||||
|
||||
@@ -395,11 +395,16 @@ describe('filters', function () {
|
||||
|
||||
it('should support upcase', () => test('{{ "Parker Moore" | upcase }}', 'PARKER MOORE'))
|
||||
|
||||
describe('url_decode', function () {
|
||||
it('should decode %xx and +',
|
||||
() => test('{{ "%27Stop%21%27+said+Fred" | url_decode }}', "'Stop!' said Fred"))
|
||||
})
|
||||
|
||||
describe('url_encode', function () {
|
||||
it('should encode @',
|
||||
() => test('{{ "[email protected]" | url_encode }}', 'john%40liquid.com'))
|
||||
it('should encode <space>',
|
||||
() => test('{{ "Tetsuro Takara" | url_encode }}', 'Tetsuro%20Takara'))
|
||||
() => test('{{ "Tetsuro Takara" | url_encode }}', 'Tetsuro+Takara'))
|
||||
})
|
||||
|
||||
describe('obj_test', function () {
|
||||
|
||||
Reference in New Issue
Block a user