diff --git a/client/src/app/utils/utils.ts b/client/src/app/utils/utils.ts index 2bace488a9..a1dec69285 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"; +import { ToolbarChip } from "@patternfly/react-core"; // Axios error @@ -111,11 +111,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 {