Skip to content

Commit

Permalink
🐛 allow svn source repos to be validated (#1346)
Browse files Browse the repository at this point in the history
- 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 <ibolton@redhat.com>
  • Loading branch information
ibolton336 authored Sep 11, 2023
1 parent e3f1630 commit 3e7ede2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions client/src/app/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as yup from "yup";
import { AxiosError } from "axios";
import { ToolbarChip } from "@patternfly/react-core";
import { StringSchema } from "yup";
import { Paths } from "@app/Paths";

// Axios error
Expand Down Expand Up @@ -112,11 +112,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 {
Expand Down

0 comments on commit 3e7ede2

Please sign in to comment.