From 4718b1f3f5cb2006fdca0ee09dd8a5e5b5fc8f7d Mon Sep 17 00:00:00 2001 From: MickLesk Date: Wed, 27 May 2026 13:26:26 +0200 Subject: [PATCH] fix: allow nested repository paths in URL validator (#585) The previous regex required exactly three path segments (host/owner/repo), rejecting nested GitLab group structures such as: https://git.example.com/group/sub-group/repo Replace with a looser pattern that only requires a host and at least one path segment after it, which covers GitHub, GitLab, Bitbucket and self-hosted instances with arbitrarily nested namespaces. --- src/server/lib/repositoryUrlValidation.js | 4 ++-- src/server/lib/repositoryUrlValidation.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server/lib/repositoryUrlValidation.js b/src/server/lib/repositoryUrlValidation.js index 4c7244d..07be80a 100644 --- a/src/server/lib/repositoryUrlValidation.js +++ b/src/server/lib/repositoryUrlValidation.js @@ -2,10 +2,10 @@ * Repository URL validation (JS mirror for server.js). */ const VALID_REPO_URL = - /^(https?:\/\/)(github\.com|gitlab\.com|bitbucket\.org|[^/]+)\/[^/]+\/[^/]+$/; + /^https?:\/\/[^/]+\/.+$/; export const REPO_URL_ERROR_MESSAGE = - 'Invalid repository URL. Supported: GitHub, GitLab, Bitbucket, and custom Git servers (e.g. https://host/owner/repo).'; + 'Invalid repository URL. Supported: GitHub, GitLab, Bitbucket, and custom Git servers (e.g. https://host/owner/repo or https://host/group/sub-group/repo).'; export function isValidRepositoryUrl(url) { if (typeof url !== 'string' || !url.trim()) return false; diff --git a/src/server/lib/repositoryUrlValidation.ts b/src/server/lib/repositoryUrlValidation.ts index 7a37f5e..acf791c 100644 --- a/src/server/lib/repositoryUrlValidation.ts +++ b/src/server/lib/repositoryUrlValidation.ts @@ -4,10 +4,10 @@ */ const VALID_REPO_URL = - /^(https?:\/\/)(github\.com|gitlab\.com|bitbucket\.org|[^/]+)\/[^/]+\/[^/]+$/; + /^https?:\/\/[^/]+\/.+$/; export const REPO_URL_ERROR_MESSAGE = - 'Invalid repository URL. Supported: GitHub, GitLab, Bitbucket, and custom Git servers (e.g. https://host/owner/repo).'; + 'Invalid repository URL. Supported: GitHub, GitLab, Bitbucket, and custom Git servers (e.g. https://host/owner/repo or https://host/group/sub-group/repo).'; export type RepoProvider = 'github' | 'gitlab' | 'bitbucket' | 'custom';