Comparing version 1.2.2 to 1.2.3
{ | ||
"name": "ng2-pipes", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"author": "Dan Revah", | ||
@@ -5,0 +5,0 @@ "description": "Useful angular2 pipes", |
@@ -609,11 +609,11 @@ # ngx-pipes | ||
```html | ||
// Returns users with `id` of 1 | ||
<!-- Returns users with `id` of 1 --> | ||
<p>{{ users | filterBy: ['id']: 1 }}</p> | ||
<!-- Output: "[{id: 1, first_name: 'John', last_name: 'Doe', work: { company: 'Foo Tech', previous_company: '' }}]" --> | ||
// filterBy also support nested properties | ||
<!-- filterBy also support nested properties --> | ||
<p>{{ users | filterBy: ['work.company']: 'Bar Tech' }}</p> | ||
<!-- Output: "[{ "id": 3, "first_name": "Bruce", "last_name": "John", "work": { "company": "Bar Tech", "previous_company": "" } }]" --> | ||
// Return users whose first name or last name is 'John'. | ||
<!-- Return users whose first name or last name is 'John'. --> | ||
<p>{{ users | filterBy: ['first_name', 'last_name']: 'John' }}</p> | ||
@@ -620,0 +620,0 @@ <!-- Output: "[{id: 1, first_name: 'John', last_name: 'Doe', work: { company: 'Foo Tech', previous_company: '' }}]" --> |
@@ -18,3 +18,5 @@ "use strict"; | ||
return helpers_1.default.isString(str) | ||
? str.toLowerCase().replace(/\s+/g, '-') | ||
? str.toLowerCase().trim() | ||
.replace(/[^\w\-]+/g, ' ') | ||
.replace(/\s+/g, '-') | ||
: str; | ||
@@ -21,0 +23,0 @@ }; |
@@ -19,2 +19,7 @@ import {SlugifyPipe} from './slugify'; | ||
}); | ||
it('Should slugify special strings', () => { | ||
expect(pipe.transform('http://example.com/foo')).toEqual('http-example-com-foo'); | ||
expect(pipe.transform(' http://example.com/foo ')).toEqual('http-example-com-foo'); | ||
}); | ||
}); |
@@ -9,5 +9,7 @@ import {PipeTransform, Pipe} from '@angular/core'; | ||
return GeneralHelper.isString(str) | ||
? str.toLowerCase().replace(/\s+/g, '-') | ||
? str.toLowerCase().trim() | ||
.replace(/[^\w\-]+/g, ' ') | ||
.replace(/\s+/g, '-') | ||
: str; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
385509
5666