1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-24 12:06:15 +01:00

support defaultMatch for getAllDecryptedForUrl

This commit is contained in:
Kyle Spearrin 2020-09-20 09:47:35 -04:00
parent 0a20face13
commit 3bf322a904
2 changed files with 9 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import { CipherType } from '../enums/cipherType';
import { UriMatchType } from '../enums/uriMatchType';
import { CipherData } from '../models/data/cipherData';
@ -21,7 +22,8 @@ export abstract class CipherService {
getAll: () => Promise<Cipher[]>;
getAllDecrypted: () => Promise<CipherView[]>;
getAllDecryptedForGrouping: (groupingId: string, folder?: boolean) => Promise<CipherView[]>;
getAllDecryptedForUrl: (url: string, includeOtherTypes?: CipherType[]) => Promise<CipherView[]>;
getAllDecryptedForUrl: (url: string, includeOtherTypes?: CipherType[],
defaultMatch?: UriMatchType) => Promise<CipherView[]>;
getAllFromApiForOrganization: (organizationId: string) => Promise<CipherView[]>;
getLastUsedForUrl: (url: string) => Promise<CipherView>;
getNextCipherForUrl: (url: string) => Promise<CipherView>;

View File

@ -328,7 +328,8 @@ export class CipherService implements CipherServiceAbstraction {
});
}
async getAllDecryptedForUrl(url: string, includeOtherTypes?: CipherType[]): Promise<CipherView[]> {
async getAllDecryptedForUrl(url: string, includeOtherTypes?: CipherType[],
defaultMatch: UriMatchType = null): Promise<CipherView[]> {
if (url == null && includeOtherTypes == null) {
return Promise.resolve([]);
}
@ -354,10 +355,12 @@ export class CipherService implements CipherServiceAbstraction {
const matchingDomains = result[0];
const ciphers = result[1];
let defaultMatch = await this.storageService.get<UriMatchType>(ConstantsService.defaultUriMatch);
if (defaultMatch == null) {
defaultMatch = await this.storageService.get<UriMatchType>(ConstantsService.defaultUriMatch);
if (defaultMatch == null) {
defaultMatch = UriMatchType.Domain;
}
}
return ciphers.filter((cipher) => {
if (cipher.deletedDate != null) {