Skip to content

Fix crash adding repos with dots in shorthand (e.g. mono/SkiaSharp.Extended)#256

Merged
PureWeen merged 3 commits intomainfrom
fix/repo-shorthand-dots
Mar 3, 2026
Merged

Fix crash adding repos with dots in shorthand (e.g. mono/SkiaSharp.Extended)#256
PureWeen merged 3 commits intomainfrom
fix/repo-shorthand-dots

Conversation

@mattleibow
Copy link
Copy Markdown
Collaborator

Problem

Adding a repo via GitHub shorthand with dots in the name (e.g. mono/SkiaSharp.Extended) crashes with Invalid URI because:
2. RepoIdFromUrl uses new Uri() which throws on non-URL strings

Fix

  • Remove the dot restriction from shorthand detection — dots in repo names are common
  • Use Uri.TryCreate with a fallback instead of new Uri() for robustness

Testing

Verified mono/SkiaSharp.Extended clones successfully after the fix.

…tended)

NormalizeRepoUrl rejected GitHub shorthand containing dots, passing the
raw string to RepoIdFromUrl which threw on new Uri(). Two fixes:
  names are common)
- Use Uri.TryCreate instead of new Uri() with a fallback for robustness

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@StephaneDelcroix StephaneDelcroix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Multi-model consensus review (5 models)

Findings

🟡 MODERATE -- RepoManagerTests.cs:58 -- Stale test assertion (4/5 models)
NormalizeRepoUrl_NonShorthand_PassesThrough("owner/repo.js") now fails because removing !input.Contains('.') causes owner/repo.js to match shorthand and expand to https://github.com/owner/repo.js. Move this case to NormalizeRepoUrl_Shorthand_ExpandsToGitHub.

🟡 MODERATE -- RepoManager.cs:299 -- Bare hostnames false-positive as GitHub shorthand (3/5 models)
Removing the dot guard means inputs like gitlab.com/myrepo expand to https://github.com/gitlab.com/myrepo. Fix: scope guard to owner segment only (!parts[0].Contains('.') ).

RepoIdFromUrl hardening (Uri.TryCreate + fallback) is clean.

Action: ⚠️ Request changes

  1. Update the stale test case
  2. Scope dot guard to owner segment only

PureWeen and others added 2 commits March 3, 2026 13:18
…s while rejecting hostnames

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PureWeen PureWeen merged commit 0708511 into main Mar 3, 2026
@PureWeen PureWeen deleted the fix/repo-shorthand-dots branch March 3, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants