Skip to content

fix: normalize SSH git URLs to strip browser query strings and fragments#578

Open
threebeats wants to merge 2 commits into
profullstack:masterfrom
threebeats:fix/git-url-query-params
Open

fix: normalize SSH git URLs to strip browser query strings and fragments#578
threebeats wants to merge 2 commits into
profullstack:masterfrom
threebeats:fix/git-url-query-params

Conversation

@threebeats
Copy link
Copy Markdown

Fixes #499

Browser-copied SSH git URLs like git@github.com:org/repo?tab=readme-ov-file#usage now have their query strings and fragments stripped via normalizeGitUrl() before being returned from resolveInput().

Previously only HTTP git URLs went through normalization. This aligns the SSH path with the HTTP path.

SSH git URLs (git@host:path and ssh://git@host/path) were not
being normalized via normalizeGitUrl, so browser-copied query
strings and fragments were preserved in the cloned URL.

This also fixes the path for --from passing the dirty URL
downstream to git clone/shallow clone operations.

Fixes profullstack#499
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 4, 2026

Greptile Summary

This PR extends the existing normalizeGitUrl() call to also cover SSH-format git URLs (git@host:path and ssh:// schemes), stripping any browser-appended query strings and fragments before the URL is returned as the canonical value. Previously only HTTP(S) git URLs were normalized.

  • Single-line logic fix in resolveInput: the SSH branch now calls normalizeGitUrl(input) instead of returning input directly, matching what the HTTP branch already did.
  • JSDoc examples for normalizeGitUrl were extended with two SSH-format examples, though the new lines have inconsistent indentation (previously flagged).

Confidence Score: 5/5

Safe to merge — the change is a one-line addition that aligns the SSH branch with the already-proven HTTP normalization path.

The fix is narrow and correct: normalizeGitUrl already handles SSH SCP-style and ssh:// URLs (the [?#].*$ regex is format-agnostic), repoNameFromGit independently strips query/fragment so there is no regression there, and the HTTP path has been exercising the same normalizer successfully. No edge cases in the changed logic introduce incorrect behavior.

No files require special attention.

Important Files Changed

Filename Overview
packages/cli/src/input.ts SSH URL branch in resolveInput now passes through normalizeGitUrl(); the fix is minimal and correct. repoNameFromGit already stripped query/fragment independently, so there is no double-stripping issue.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["resolveInput(raw)"] --> B["trim input"]
    B --> C{SSH URL?\ngit@ or ssh://}
    C -- Yes --> D["normalizeGitUrl(input)\n[NEW: was skipped before]"]
    D --> E["repoNameFromGit(input)"]
    E --> F["return {kind:'git', value:normalized}"]
    C -- No --> G{HTTP git URL?\n.git or forge domain}
    G -- Yes --> H["normalizeGitUrl(input)"]
    H --> I["repoNameFromGit(input)"]
    I --> J["return {kind:'git', value:normalized}"]
    G -- No --> K{https?://}
    K -- Yes --> L["normalizeUrl(input)\nreturn {kind:'url'}"]
    K -- No --> M["local path / doc\nreturn {kind:'path'|'doc'}"]

    style D fill:#d4edda,stroke:#28a745
Loading

Reviews (2): Last reviewed commit: "docs: add SSH URL examples to normalizeG..." | Re-trigger Greptile

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.

Bug: git repo URLs keep browser query strings and fragments

1 participant