mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 04:40:39 -07:00
fix: url_encode throws on undefined value, fixes #479
This commit is contained in:
@@ -1,2 +1,4 @@
|
|||||||
export const urlDecode = (x: string) => x.split('+').map(decodeURIComponent).join(' ')
|
import { stringify } from '../../util/underscore'
|
||||||
export const urlEncode = (x: string) => x.split(' ').map(encodeURIComponent).join('+')
|
|
||||||
|
export const urlDecode = (x: string) => stringify(x).split('+').map(decodeURIComponent).join(' ')
|
||||||
|
export const urlEncode = (x: string) => stringify(x).split(' ').map(encodeURIComponent).join('+')
|
||||||
|
|||||||
@@ -199,4 +199,12 @@ describe('Issues', function () {
|
|||||||
const html = engine.parseAndRenderSync('{{foo | size}}-{{bar.coo}}', { foo: 'foo', bar: Object.create({ coo: 'COO' }) })
|
const html = engine.parseAndRenderSync('{{foo | size}}-{{bar.coo}}', { foo: 'foo', bar: Object.create({ coo: 'COO' }) })
|
||||||
expect(html).to.equal('3-')
|
expect(html).to.equal('3-')
|
||||||
})
|
})
|
||||||
|
it('#479 url_encode throws on undefined value', async () => {
|
||||||
|
const engine = new Liquid({
|
||||||
|
strictVariables: false
|
||||||
|
})
|
||||||
|
const tpl = engine.parse('{{ v | url_encode }}')
|
||||||
|
const html = await engine.render(tpl, { v: undefined })
|
||||||
|
expect(html).to.equal('')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user