We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0f4e6d9 commit a00945cCopy full SHA for a00945c
src/builtin/filters/html.ts
@@ -14,7 +14,7 @@ const unescapeMap = {
14
}
15
16
function escape (str: string) {
17
- return String(str).replace(/&|<|>|"|'/g, m => escapeMap[m])
+ return !!str ? String(str).replace(/&|<|>|"|'/g, m => escapeMap[m]) : ""
18
19
20
function unescape (str: string) {
test/integration/builtin/filters/html.ts
@@ -12,6 +12,9 @@ describe('filters/html', function () {
12
it('should escape function', function () {
13
return test('{{ func | escape }}', 'function () { }')
})
+ it('should escape undefined', function () {
+ return test('{{ nonExistent.value | escape }}', '')
+ })
describe('escape_once', function () {
it('should do escape', () =>
0 commit comments