Fix repo URL validation rejecting non-GitHub and self-hosted forges#60
Merged
Merged
Conversation
Problem:
The frontend only accepted URLs containing the literal string
'github.com':
if (projectUrl.includes('github.com') === false) { reject }
This rejected every GitLab, Codeberg, and Bitbucket URL outright,
including self-hosted instances like:
https://gitlab.windenergy.dtu.dk/pyconturb/pyconturb
Requests were blocked client-side before ever reaching the backend,
even though repository_provider.py already supports GitHub, GitLab
(including self-hosted, via _detect_engine()), Codeberg, and Bitbucket.
Fix:
Replace the single-host substring check with a structural check: any
URL with a valid scheme/host and an /owner/repo-shaped path is
accepted client-side. Real host support is left to the backend, which
already has detection logic and returns UnsupportedHostError for
genuinely unsupported hosts.
const url = new URL(projectUrl);
isValidRepoUrl = /^\/[^/]+\/[^/]+/.test(url.pathname);
Signed-off-by: Pippiblip <peterpie575@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
The frontend only accepted URLs containing the literal string 'github.com':
if (projectUrl.includes('github.com') === false) { reject }
This rejected every GitLab, Codeberg, and Bitbucket URL outright, including self-hosted instances like:
https://gitlab.windenergy.dtu.dk/pyconturb/pyconturb
Requests were blocked client-side before ever reaching the backend, even though repository_provider.py already supports GitHub, GitLab (including self-hosted, via _detect_engine()), Codeberg, and Bitbucket.
Fix:
Replace the single-host substring check with a structural check: any URL with a valid scheme/host and an /owner/repo-shaped path is accepted client-side. Real host support is left to the backend, which already has detection logic and returns UnsupportedHostError for genuinely unsupported hosts.
const url = new URL(projectUrl);
isValidRepoUrl = /^/[^/]+/[^/]+/.test(url.pathname);