diff --git a/apps/browser-extension/src/entrypoints/popup/components/CredentialDetails/HeaderBlock.tsx b/apps/browser-extension/src/entrypoints/popup/components/CredentialDetails/HeaderBlock.tsx index 141deb238..3f0ee4227 100644 --- a/apps/browser-extension/src/entrypoints/popup/components/CredentialDetails/HeaderBlock.tsx +++ b/apps/browser-extension/src/entrypoints/popup/components/CredentialDetails/HeaderBlock.tsx @@ -21,14 +21,18 @@ const HeaderBlock: React.FC = ({ credential }) => (

{credential.ServiceName}

{credential.ServiceUrl && ( - - {credential.ServiceUrl} - + /^https?:\/\//i.test(credential.ServiceUrl) ? ( + + {credential.ServiceUrl} + + ) : ( + {credential.ServiceUrl} + ) )}
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/CredentialAddEdit.tsx b/apps/browser-extension/src/entrypoints/popup/pages/CredentialAddEdit.tsx index 614258a98..41df53ac7 100644 --- a/apps/browser-extension/src/entrypoints/popup/pages/CredentialAddEdit.tsx +++ b/apps/browser-extension/src/entrypoints/popup/pages/CredentialAddEdit.tsx @@ -98,7 +98,7 @@ const CredentialAddEdit: React.FC = () => { Username: "", Password: "", ServiceName: "", - ServiceUrl: "", + ServiceUrl: "https://", Notes: "", Alias: { FirstName: "", @@ -401,6 +401,11 @@ const CredentialAddEdit: React.FC = () => { birthdate = IdentityHelperUtils.normalizeBirthDateForDb(birthdate); } + // Clean up empty protocol-only URLs + if (data.ServiceUrl === 'http://' || data.ServiceUrl === 'https://') { + data.ServiceUrl = ''; + } + // If we're creating a new credential and mode is random, generate random values here if (!isEditMode && mode === 'random') { // Generate random values now and then read them from the form fields to manually assign to the credentialToSave object @@ -413,6 +418,9 @@ const CredentialAddEdit: React.FC = () => { data.Alias.BirthDate = birthdate; data.Alias.Gender = watch('Alias.Gender'); data.Alias.Email = watch('Alias.Email'); + // Clean up ServiceUrl for random mode too + const serviceUrl = watch('ServiceUrl'); + data.ServiceUrl = (serviceUrl === 'http://' || serviceUrl === 'https://') ? '' : serviceUrl; } // Extract favicon from service URL if the credential has one diff --git a/apps/browser-extension/src/i18n/locales/en.json b/apps/browser-extension/src/i18n/locales/en.json index 001c4fdd3..351db0486 100644 --- a/apps/browser-extension/src/i18n/locales/en.json +++ b/apps/browser-extension/src/i18n/locales/en.json @@ -237,13 +237,9 @@ "birthDate": "Birth Date", "birthDatePlaceholder": "YYYY-MM-DD", "metadata": "Metadata", - "errors": { - "invalidUrl": "Please enter a valid URL" - }, "validation": { "required": "This field is required", "serviceNameRequired": "Service name is required", - "invalidUrl": "Invalid URL format", "invalidEmail": "Invalid email format", "invalidDateFormat": "Date must be in YYYY-MM-DD format" } diff --git a/apps/mobile-app/app/(tabs)/credentials/[id].tsx b/apps/mobile-app/app/(tabs)/credentials/[id].tsx index 8a647ed20..4c6ca5342 100644 --- a/apps/mobile-app/app/(tabs)/credentials/[id].tsx +++ b/apps/mobile-app/app/(tabs)/credentials/[id].tsx @@ -136,11 +136,17 @@ export default function CredentialDetailsScreen() : React.ReactNode { {credential.ServiceName} {credential.ServiceUrl && ( - Linking.openURL(credential.ServiceUrl!)}> - + /^https?:\/\//i.test(credential.ServiceUrl) ? ( + Linking.openURL(credential.ServiceUrl!)}> + + {credential.ServiceUrl} + + + ) : ( + {credential.ServiceUrl} - + ) )} diff --git a/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx b/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx index a18e31f32..9e8f25a7c 100644 --- a/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx +++ b/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx @@ -62,7 +62,7 @@ export default function AddEditCredentialScreen() : React.ReactNode { Username: "", Password: "", ServiceName: "", - ServiceUrl: "", + ServiceUrl: "https://", Notes: "", Alias: { FirstName: "", @@ -255,7 +255,7 @@ export default function AddEditCredentialScreen() : React.ReactNode { Username: data.Username, Password: data.Password, ServiceName: data.ServiceName, - ServiceUrl: data.ServiceUrl, + ServiceUrl: (data.ServiceUrl === 'http://' || data.ServiceUrl === 'https://') ? '' : data.ServiceUrl, Notes: data.Notes, Alias: { FirstName: data.Alias.FirstName, @@ -274,7 +274,8 @@ export default function AddEditCredentialScreen() : React.ReactNode { credentialToSave.Username = watch('Username'); credentialToSave.Password = watch('Password'); credentialToSave.ServiceName = watch('ServiceName'); - credentialToSave.ServiceUrl = watch('ServiceUrl'); + const serviceUrl = watch('ServiceUrl'); + credentialToSave.ServiceUrl = (serviceUrl === 'http://' || serviceUrl === 'https://') ? '' : serviceUrl; credentialToSave.Notes = watch('Notes'); credentialToSave.Alias.FirstName = watch('Alias.FirstName'); credentialToSave.Alias.LastName = watch('Alias.LastName'); diff --git a/apps/mobile-app/i18n/locales/en.json b/apps/mobile-app/i18n/locales/en.json index 62e27d012..39524c56a 100644 --- a/apps/mobile-app/i18n/locales/en.json +++ b/apps/mobile-app/i18n/locales/en.json @@ -360,7 +360,6 @@ "validation": { "required": "This field is required", "serviceNameRequired": "Service name is required", - "invalidUrlFormat": "Invalid URL format", "invalidDateFormat": "Date must be in YYYY-MM-DD format", "invalidEmailFormat": "Invalid email format" }, diff --git a/apps/server/AliasVault.Client/Main/Pages/Credentials/View.razor b/apps/server/AliasVault.Client/Main/Pages/Credentials/View.razor index bcec8516d..6e7764cb2 100644 --- a/apps/server/AliasVault.Client/Main/Pages/Credentials/View.razor +++ b/apps/server/AliasVault.Client/Main/Pages/Credentials/View.razor @@ -39,12 +39,14 @@ else

@Alias.Service.Name

@if (Alias.Service.Url is not null && Alias.Service.Url.Length > 0) { - var url = Alias.Service.Url; - if (!url.StartsWith("http://") && !url.StartsWith("https://")) + @if (Alias.Service.Url.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || Alias.Service.Url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { - url = "https://" + url; + @Alias.Service.Url + } + else + { + @Alias.Service.Url } - @Alias.Service.Url }