diff --git a/desktop/src/views/Workspaces/CreateWorkspace/WorkspaceSourceInput.tsx b/desktop/src/views/Workspaces/CreateWorkspace/WorkspaceSourceInput.tsx index 696f717f4..b66e3f163 100644 --- a/desktop/src/views/Workspaces/CreateWorkspace/WorkspaceSourceInput.tsx +++ b/desktop/src/views/Workspaces/CreateWorkspace/WorkspaceSourceInput.tsx @@ -28,9 +28,9 @@ import { TWorkspaceSourceType } from "@/types" // WARN: Make sure these match the regexes in /pkg/git/git.go const GIT_REPOSITORY_PATTERN = - "((?:(?:https?|git|ssh)://)?(?:[^@/\\n]+@)?(?:[^:/\\n]+)(?:[:/][^/\\n]+)+(?:\\.git)?)" + "((?:(?:https?|git|ssh|file):\/\/)?\/?(?:[^@\/\n]+@)?(?:[^:\/\n]+)(?:[:\/][^\/\n]+)+(?:\.git)?)" const GIT_REPOSITORY_REGEX = new RegExp(GIT_REPOSITORY_PATTERN) -const BRANCH_REGEX = new RegExp(`^${GIT_REPOSITORY_PATTERN}@([a-zA-Z0-9\\./\\-\\_]+)$`) +const BRANCH_REGEX = new RegExp(`^${GIT_REPOSITORY_PATTERN}(?:@([a-zA-Z0-9\./\-\_]+))?$`) const COMMIT_REGEX = new RegExp(`^${GIT_REPOSITORY_PATTERN}@sha256:([a-zA-Z0-9]+)$`) const PR_REGEX = new RegExp(`^${GIT_REPOSITORY_PATTERN}@pull\\/([0-9]+)\\/head$`) const SUBPATH_REGEX = new RegExp(`^${GIT_REPOSITORY_PATTERN}@subpath:([a-zA-Z0-9\\./\\-\\_]+)$`)