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.
This commit is contained in:
MickLesk
2026-05-27 13:26:26 +02:00
parent 10aedd8bd9
commit 4718b1f3f5
2 changed files with 4 additions and 4 deletions

View File

@@ -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;

View File

@@ -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';