Skip to content

Commit

Permalink
🐛 allow svn source repos to be validated
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Sep 11, 2023
1 parent 22b29a6 commit b34dc26
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 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 { FormGroupProps, ToolbarChip } from "@patternfly/react-core";
import { StringSchema } from "yup";
import { ToolbarChip } from "@patternfly/react-core";

// Axios error

Expand Down Expand Up @@ -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);

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L119 - L120 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 b34dc26

Please sign in to comment.