mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-05 23:53:21 +00:00
* Unpackage-ify jslib * Adjust .tsconfig path for root and apply to jslib * Rebuild package-lock.json * Disable husky in CI * Revert an incorrect find/replace * Add jslib/shared/.eslintrc rules to root eslintrc * Revert package.json change to ignore spec files when linting * Ensure custom matcher gets imported in jslib tests * Fix small workflow bugs from merging * Try and get CI builds moving again * Always sign and notorize builds in CI * Revert erroneous verion bump
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { Pipe, PipeTransform } from "@angular/core";
|
|
|
|
import { CipherView } from "@/jslib/common/src/models/view/cipherView";
|
|
|
|
@Pipe({
|
|
name: "searchCiphers",
|
|
})
|
|
export class SearchCiphersPipe implements PipeTransform {
|
|
transform(ciphers: CipherView[], searchText: string, deleted = false): CipherView[] {
|
|
if (ciphers == null || ciphers.length === 0) {
|
|
return [];
|
|
}
|
|
|
|
if (searchText == null || searchText.length < 2) {
|
|
return ciphers.filter((c) => {
|
|
return deleted !== c.isDeleted;
|
|
});
|
|
}
|
|
|
|
searchText = searchText.trim().toLowerCase();
|
|
return ciphers.filter((c) => {
|
|
if (deleted !== c.isDeleted) {
|
|
return false;
|
|
}
|
|
if (c.name != null && c.name.toLowerCase().indexOf(searchText) > -1) {
|
|
return true;
|
|
}
|
|
if (searchText.length >= 8 && c.id.startsWith(searchText)) {
|
|
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;
|
|
});
|
|
}
|
|
}
|