Add URL to credential search filter logic (#771)

This commit is contained in:
Leendert de Borst
2025-04-18 13:17:08 +02:00
parent 8dcacd2ea4
commit 9e1eb67ae8
3 changed files with 17 additions and 14 deletions

View File

@@ -11,6 +11,7 @@ import { PasswordSettingsResponse } from '@/utils/types/messaging/PasswordSettin
import SqliteClient from '../../utils/SqliteClient';
import { BaseIdentityGenerator } from '@/utils/generators/Identity/implementations/base/BaseIdentityGenerator';
import { StringResponse } from '@/utils/types/messaging/StringResponse';
import { Credential } from '@/utils/types/Credential';
// TODO: store generic setting constants somewhere else.
export const DISABLED_SITES_KEY = 'local:aliasvault_disabled_sites';
@@ -159,7 +160,7 @@ export function removeExistingPopup(container: HTMLElement) : void {
/**
* Create auto-fill popup
*/
export function createAutofillPopup(input: HTMLInputElement, credentials: Credential[] | undefined, rootContainer: HTMLElement) : void {
export function createAutofillPopup(input: HTMLInputElement, credentials: Credential[] | undefined, rootContainer: HTMLElement) : void {
// Disable browser's native autocomplete to avoid conflicts with AliasVault's autocomplete.
input.setAttribute('autocomplete', 'false');
const popup = createBasePopup(input, rootContainer);
@@ -265,7 +266,7 @@ export function createAutofillPopup(input: HTMLInputElement, credentials: Creden
// Get password settings from background
const passwordSettingsResponse = await sendMessage('GET_PASSWORD_SETTINGS', {}, 'background') as PasswordSettingsResponse;
// Initialize password generator with the retrieved settings
const passwordGenerator = new PasswordGenerator(passwordSettingsResponse.settings);
const password = passwordGenerator.generateRandomPassword();
@@ -493,7 +494,7 @@ function handleSearchInput(searchInput: HTMLInputElement, credentials: Credentia
const searchTerm = searchInput.value.toLowerCase();
// Ensure we have unique credentials
const uniqueCredentials = Array.from(new Map(credentials.map(cred => [cred.Id, cred])).values());
const uniqueCredentials = Array.from(new Map(credentials.map(cred => [cred.id, cred])).values());
let filteredCredentials;
if (searchTerm === '') {
@@ -517,7 +518,7 @@ function handleSearchInput(searchInput: HTMLInputElement, credentials: Credentia
filteredCredentials = uniqueCredentials.filter(cred => {
const searchableFields = [
cred.ServiceName?.toLowerCase(),
cred.Username?.toLowerCase(),
cred.Username?.toLowerCase(),
cred.Alias?.Email?.toLowerCase(),
cred.ServiceUrl?.toLowerCase()
];
@@ -993,25 +994,25 @@ export async function createAliasCreationPopup(defaultName: string, rootContaine
// Add error styling to fields
customEmail.classList.add('av-create-popup-input-error');
customUsername.classList.add('av-create-popup-input-error');
// Add error messages after labels
const emailLabel = customEmail.previousElementSibling as HTMLLabelElement;
const usernameLabel = customUsername.previousElementSibling as HTMLLabelElement;
if (!emailLabel.querySelector('.av-create-popup-error-text')) {
const emailError = document.createElement('span');
emailError.className = 'av-create-popup-error-text';
emailError.textContent = 'Enter email and/or username';
emailLabel.appendChild(emailError);
}
if (!usernameLabel.querySelector('.av-create-popup-error-text')) {
const usernameError = document.createElement('span');
usernameError.className = 'av-create-popup-error-text';
usernameError.textContent = 'Enter email and/or username';
usernameLabel.appendChild(usernameError);
}
/**
* Remove error styling.
*/
@@ -1027,10 +1028,10 @@ export async function createAliasCreationPopup(defaultName: string, rootContaine
usernameError.remove();
}
};
customEmail.addEventListener('input', removeError, { once: true });
customUsername.addEventListener('input', removeError, { once: true });
return;
}
@@ -1056,7 +1057,7 @@ export async function createAliasCreationPopup(defaultName: string, rootContaine
};
customInput.addEventListener('keyup', handleCustomEnter);
customEmail.addEventListener('keyup', handleCustomEnter);
customEmail.addEventListener('keyup', handleCustomEnter);
customUsername.addEventListener('keyup', handleCustomEnter);
passwordPreview.addEventListener('keyup', handleCustomEnter);
@@ -1108,7 +1109,7 @@ async function getFaviconBytes(document: Document): Promise<Uint8Array | null> {
const TARGET_WIDTH = 96; // Resize target width
const faviconLinks = [
...Array.from(document.querySelectorAll('link[rel="icon"][type="image/svg+xml"]')),
...Array.from(document.querySelectorAll('link[rel="icon"][type="image/svg+xml"]')),
...Array.from(document.querySelectorAll('link[rel="icon"][sizes="96x96"]')),
...Array.from(document.querySelectorAll('link[rel="icon"][sizes="128x128"]')),
...Array.from(document.querySelectorAll('link[rel="icon"][sizes="48x48"]')),

View File

@@ -109,7 +109,8 @@ const CredentialsList: React.FC = () => {
const searchableFields = [
cred.ServiceName?.toLowerCase(),
cred.Username?.toLowerCase(),
cred.Alias?.Email?.toLowerCase()
cred.Alias?.Email?.toLowerCase(),
cred.ServiceUrl?.toLowerCase()
];
return searchableFields.some(field => field?.includes(searchLower));
});

View File

@@ -154,7 +154,8 @@ export default function CredentialsScreen() {
return (
credential.ServiceName?.toLowerCase().includes(searchLower) ||
credential.Username?.toLowerCase().includes(searchLower) ||
credential.Alias?.Email?.toLowerCase().includes(searchLower)
credential.Alias?.Email?.toLowerCase().includes(searchLower) ||
credential.ServiceUrl?.toLowerCase().includes(searchLower)
);
});