# git: Detect SCP remotes with non-standard SSH usernames \(\#59457\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/790b73e2fb79f75bcebc0ca69845660a75992b9d)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 790b73e2fb79f75bcebc0ca69845660a75992b9d

Requested commit: 790b73e2fb79f75bcebc0ca69845660a75992b9d

Commit: 790b73e2fb79f75bcebc0ca69845660a75992b9d

Tree: 08dc1b28592b57fb45e982ef4012cd2148d8f861

Author: Ibrahim Khan

Committer: GitHub

## Message

```
git: Detect SCP remotes with non-standard SSH usernames (#59457)

# Objective

The scp-style remote rewrite only treats a leading `user@` as SSH when
the username matches `^[0-9a-zA-Z\-_]+@`. Remotes like
`first.last@host:owner/repo.git` (common on self-hosted instances that
authenticate as the developer) therefore fail to parse, so no hosting
provider matches and Copy Permalink, git blame links, and Open in
browser silently break. Extends #21508, which added `org-000000@`.

## Solution

Match the scp username by exclusion (`^[^/@:]+@`): anything before the
`@` that isn't the `:`/`/` delimiting host and path, mirroring git's scp
syntax. The pattern stays anchored, so `scheme://user@host` URLs aren't
misclassified, and it's a strict superset of the old one, so existing
remotes are unaffected.

## Testing

`cargo test -p git` passes, including two new
`test_parsing_valid_remote_urls` cases — a dotted-username scp remote
(the fix) and a `https://user@host` regression guard. `cargo fmt` and
`cargo clippy -p git` are clean.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed detection of SSH git remotes whose username contains characters
such as `.` (e.g. `first.last@host:owner/repo.git`), which previously
broke permalinks, git blame links, and "open in browser".

---------

Co-authored-by: dino <dinojoaocosta@gmail.com>
```

## Parents

- [d1eb52166e0eb4c45bd171c14e2fdcd148ed17d0](https://git.cafe/gitcafe/zed/commit/d1eb52166e0eb4c45bd171c14e2fdcd148ed17d0?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/790b73e2fb79f75bcebc0ca69845660a75992b9d?format=markdown)
