Skip to content

Commit

Permalink
🐛 allow svn source repos to be validated
Browse files Browse the repository at this point in the history
Signed-off-by: ibolton336 <ibolton@redhat.com>
  • Loading branch information
ibolton336 committed Sep 11, 2023
1 parent f52d7e2 commit 5d4440a
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);

Check warning on line 121 in client/src/app/utils/utils.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/utils/utils.ts#L120-L121

Added lines #L120 - L121 were not covered by tests

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 5d4440a

Please sign in to comment.