mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
37 lines
1019 B
TypeScript
37 lines
1019 B
TypeScript
import {
|
|
Pipe,
|
|
PipeTransform,
|
|
} from '@angular/core';
|
|
|
|
import { CipherView } from '../../models/view/cipherView';
|
|
|
|
@Pipe({
|
|
name: 'searchCiphers',
|
|
})
|
|
export class SearchCiphersPipe implements PipeTransform {
|
|
transform(ciphers: CipherView[], searchText: string): CipherView[] {
|
|
if (ciphers == null || ciphers.length === 0) {
|
|
return [];
|
|
}
|
|
|
|
if (searchText == null || searchText.length < 2) {
|
|
return ciphers;
|
|
}
|
|
|
|
searchText = searchText.toLowerCase();
|
|
return ciphers.filter((c) => {
|
|
if (c.name != null && c.name.toLowerCase().indexOf(searchText) > -1) {
|
|
return true;
|
|
}
|
|
if (c.subTitle != null && c.subTitle.toLowerCase().indexOf(searchText) > -1) {
|
|
return true;
|
|
}
|
|
if (c.login && c.login.uri != null && c.login.uri.toLowerCase().indexOf(searchText) > -1) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
});
|
|
}
|
|
}
|