From 529f99b44ff5cc5b6d3401a16b912d885b8b5325 Mon Sep 17 00:00:00 2001 From: Ian Bolton Date: Mon, 2 Oct 2023 09:48:29 -0400 Subject: [PATCH] :bug: (Backport release-0.2) - allow svn source repos to be validated (#1346) (#1417) - Fixes customer case 03608826 "When setting up an a new application to be analysed by the MTA, we select Subversion as the repository type and enter the URL with the SVN protocol. The UI tells us that this is not a valid URL for a Subversion repository. Changing the URL protocol to HTTP makes the error go away but our department wide Subversion server is set to use only SVN protocol and cannot be changed. This leaves us unable to scan an application a Subversion hosted application with a valid SVN URL." Adds regex to allow SVN repos to be validated when adding as a source repo to applications Signed-off-by: ibolton336 --- client/src/app/utils/utils.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client/src/app/utils/utils.ts b/client/src/app/utils/utils.ts index 33eccf991b..e9fa862b4e 100644 --- a/client/src/app/utils/utils.ts +++ b/client/src/app/utils/utils.ts @@ -1,6 +1,6 @@ +import * as yup from "yup"; import { AxiosError } from "axios"; import { FormGroupProps, ToolbarChip } from "@patternfly/react-core"; -import { StringSchema } from "yup"; // Axios error @@ -104,11 +104,15 @@ export const gitUrlRegex = export const standardStrictURLRegex = /https:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/; -export const customURLValidation = (schema: StringSchema) => { +export const svnUrlRegex = /^svn:\/\/[^\s/$.?#].[^\s]*$/; + +export const customURLValidation = (schema: yup.StringSchema) => { const containsURL = (string: string) => - gitUrlRegex.test(string) || standardURLRegex.test(string); + gitUrlRegex.test(string) || + standardURLRegex.test(string) || + svnUrlRegex.test(string); - return schema.test("gitUrlTest", "Must be a valid URL.", (value) => { + return schema.test("urlValidation", "Must be a valid URL.", (value) => { if (value) { return containsURL(value); } else {