From 2b3aab552df10d6c828f11753658f0e32b792353 Mon Sep 17 00:00:00 2001
From: krishna2323 <belivethatkg@gmail.com>
Date: Thu, 7 Nov 2024 04:43:39 +0530
Subject: [PATCH] fix: Bank account - Website in upper-case letters is accepted
 despite validation error.

Signed-off-by: krishna2323 <belivethatkg@gmail.com>
---
 src/languages/en.ts                                 |  2 +-
 src/languages/es.ts                                 |  2 +-
 src/libs/ValidationUtils.ts                         |  3 +--
 .../iou/request/step/IOURequestStepCompanyInfo.tsx  |  2 +-
 .../invoices/WorkspaceInvoicingDetailsWebsite.tsx   | 13 +++++--------
 5 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/languages/en.ts b/src/languages/en.ts
index 38b11e9fea38..f621f51abbab 100755
--- a/src/languages/en.ts
+++ b/src/languages/en.ts
@@ -1918,7 +1918,7 @@ const translations = {
             noBankAccountAvailable: "Sorry, there's no bank account available.",
             noBankAccountSelected: 'Please choose an account.',
             taxID: 'Please enter a valid tax ID number.',
-            website: 'Please enter a valid website using lower-case letters.',
+            website: 'Please enter a valid website.',
             zipCode: `Please enter a valid ZIP code using the format: ${CONST.COUNTRY_ZIP_REGEX_DATA.US.samples}.`,
             phoneNumber: 'Please enter a valid phone number.',
             companyName: 'Please enter a valid business name.',
diff --git a/src/languages/es.ts b/src/languages/es.ts
index ab404143d030..5b2efc656a52 100644
--- a/src/languages/es.ts
+++ b/src/languages/es.ts
@@ -1937,7 +1937,7 @@ const translations = {
             noBankAccountAvailable: 'Lo sentimos, no hay ninguna cuenta bancaria disponible.',
             noBankAccountSelected: 'Por favor, elige una cuenta bancaria.',
             taxID: 'Por favor, introduce un número de identificación fiscal válido.',
-            website: 'Por favor, introduce un sitio web válido. El sitio web debe estar en minúsculas.',
+            website: 'Por favor, introduce un sitio web válido.',
             zipCode: `Formato de código postal incorrecto. Formato aceptable: ${CONST.COUNTRY_ZIP_REGEX_DATA.US.samples}.`,
             phoneNumber: 'Por favor, introduce un teléfono válido.',
             companyName: 'Por favor, introduce un nombre comercial legal válido.',
diff --git a/src/libs/ValidationUtils.ts b/src/libs/ValidationUtils.ts
index fbc1aefe30ce..664f2416867a 100644
--- a/src/libs/ValidationUtils.ts
+++ b/src/libs/ValidationUtils.ts
@@ -246,8 +246,7 @@ function getDatePassedError(inputDate: string): string {
  * http/https/ftp URL scheme required.
  */
 function isValidWebsite(url: string): boolean {
-    const isLowerCase = url === url.toLowerCase();
-    return new RegExp(`^${Url.URL_REGEX_WITH_REQUIRED_PROTOCOL}$`, 'i').test(url) && isLowerCase;
+    return new RegExp(`^${Url.URL_REGEX_WITH_REQUIRED_PROTOCOL}$`, 'i').test(url);
 }
 
 /** Checks if the domain is public */
diff --git a/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx b/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx
index 1c2f14dbbb2b..d6cb1e71407f 100644
--- a/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx
+++ b/src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx
@@ -56,7 +56,7 @@ function IOURequestStepCompanyInfo({route, report, transaction}: IOURequestStepC
                 if (!ValidationUtils.isValidWebsite(companyWebsite)) {
                     errors.companyWebsite = translate('bankAccount.error.website');
                 } else {
-                    const domain = Url.extractUrlDomain(values.companyWebsite);
+                    const domain = Url.extractUrlDomain(companyWebsite);
 
                     if (!domain || !Str.isValidDomainName(domain)) {
                         errors.companyWebsite = translate('iou.invalidDomainError');
diff --git a/src/pages/workspace/invoices/WorkspaceInvoicingDetailsWebsite.tsx b/src/pages/workspace/invoices/WorkspaceInvoicingDetailsWebsite.tsx
index e9c5d8e35187..aead9b03f49a 100644
--- a/src/pages/workspace/invoices/WorkspaceInvoicingDetailsWebsite.tsx
+++ b/src/pages/workspace/invoices/WorkspaceInvoicingDetailsWebsite.tsx
@@ -1,6 +1,6 @@
 import type {StackScreenProps} from '@react-navigation/stack';
 import {Str} from 'expensify-common';
-import React, {useMemo} from 'react';
+import React from 'react';
 import {useOnyx} from 'react-native-onyx';
 import FormProvider from '@components/Form/FormProvider';
 import InputWrapper from '@components/Form/InputWrapper';
@@ -11,7 +11,6 @@ import TextInput from '@components/TextInput';
 import useAutoFocusInput from '@hooks/useAutoFocusInput';
 import useLocalize from '@hooks/useLocalize';
 import useThemeStyles from '@hooks/useThemeStyles';
-import {getDefaultCompanyWebsite} from '@libs/BankAccountUtils';
 import * as Url from '@libs/Url';
 import * as ValidationUtils from '@libs/ValidationUtils';
 import Navigation from '@navigation/Navigation';
@@ -32,9 +31,6 @@ function WorkspaceInvoicingDetailsWebsite({route}: WorkspaceInvoicingDetailsWebs
     const {inputCallbackRef} = useAutoFocusInput();
     const styles = useThemeStyles();
     const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
-    const [session] = useOnyx(ONYXKEYS.SESSION);
-    const [user] = useOnyx(ONYXKEYS.USER);
-    const defaultWebsiteExample = useMemo(() => getDefaultCompanyWebsite(session, user), [session, user]);
 
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     const submit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_INVOICES_COMPANY_WEBSITE_FORM>) => {
@@ -49,10 +45,11 @@ function WorkspaceInvoicingDetailsWebsite({route}: WorkspaceInvoicingDetailsWebs
         const errors = ValidationUtils.getFieldRequiredErrors(values, [INPUT_IDS.COMPANY_WEBSITE]);
 
         if (values.companyWebsite) {
-            if (!ValidationUtils.isValidWebsite(Str.sanitizeURL(values.companyWebsite, CONST.COMPANY_WEBSITE_DEFAULT_SCHEME))) {
+            const companyWebsite = Str.sanitizeURL(values.companyWebsite, CONST.COMPANY_WEBSITE_DEFAULT_SCHEME);
+            if (!ValidationUtils.isValidWebsite(companyWebsite)) {
                 errors.companyWebsite = translate('bankAccount.error.website');
             } else {
-                const domain = Url.extractUrlDomain(values.companyWebsite);
+                const domain = Url.extractUrlDomain(companyWebsite);
 
                 if (!domain || !Str.isValidDomainName(domain)) {
                     errors.companyWebsite = translate('iou.invalidDomainError');
@@ -91,7 +88,7 @@ function WorkspaceInvoicingDetailsWebsite({route}: WorkspaceInvoicingDetailsWebs
                         label={translate('workspace.invoices.companyWebsite')}
                         accessibilityLabel={translate('workspace.invoices.companyWebsite')}
                         role={CONST.ROLE.PRESENTATION}
-                        defaultValue={policy?.invoice?.companyWebsite ?? defaultWebsiteExample}
+                        defaultValue={policy?.invoice?.companyWebsite}
                         ref={inputCallbackRef}
                         inputMode={CONST.INPUT_MODE.URL}
                     />
