feature: url_decode, working on #94

This commit is contained in:
harttle
2018-10-08 10:37:24 +08:00
parent d504c8107e
commit 6af631b77b
2 changed files with 8 additions and 2 deletions
+2 -1
View File
@@ -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) {
+6 -1
View File
@@ -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 () {