Comparing version 0.3.6 to 0.3.7
{ | ||
"name": "ng2-pipes", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"author": "Dan Revah", | ||
@@ -5,0 +5,0 @@ "description": "Useful angular2 pipes", |
@@ -16,6 +16,6 @@ import {StripTagsPipe} from "./strip-tags"; | ||
it('Should strip tags only tags which are not allowed', () => { | ||
expect(pipe.transform('<a href="">foo</a><p class="foo">bar</p>', [['p']])).toEqual('foo<p class="foo">bar</p>'); | ||
expect(pipe.transform('<a href="">foo</a><p class="foo">bar</p>', [['a']])).toEqual('<a href="">foo</a>bar'); | ||
expect(pipe.transform('<a href="">foo</a><p class="foo">bar</p>', [['p', 'a']])).toEqual('<a href="">foo</a><p class="foo">bar</p>'); | ||
expect(pipe.transform('<a href="">foo</a><p class="foo">bar</p>', 'p')).toEqual('foo<p class="foo">bar</p>'); | ||
expect(pipe.transform('<a href="">foo</a><p class="foo">bar</p>', 'a')).toEqual('<a href="">foo</a>bar'); | ||
expect(pipe.transform('<a href="">foo</a><p class="foo">bar</p>', 'p', 'a')).toEqual('<a href="">foo</a><p class="foo">bar</p>'); | ||
}); | ||
}); |
@@ -7,3 +7,3 @@ import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
transform(text:string, [allowedTags = []]:any[] = []):string { | ||
transform(text:string, ...allowedTags: any[]):string { | ||
return allowedTags.length > 0 | ||
@@ -10,0 +10,0 @@ ? text.replace(new RegExp(`<(?!\/?(${allowedTags.join('|')})\s*\/?)[^>]+>`, 'g'), '') |
214144