Parse SSH URL usernames consistently
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / macos-client (macos-aarch64, macos-14) (push) Canceled after 0s
ci / macos-client (macos-x86_64, macos-13) (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / macos-client (macos-aarch64, macos-14) (push) Canceled after 0s
ci / macos-client (macos-x86_64, macos-13) (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s
This commit is contained in:
+9
-1
@@ -786,7 +786,7 @@ fn selected_sdk_udp_host(
|
||||
fn user_from_destination(destination: &str) -> Option<String> {
|
||||
destination
|
||||
.rsplit_once('@')
|
||||
.map(|(user, _)| user.to_string())
|
||||
.map(|(user, _)| user.strip_prefix("ssh://").unwrap_or(user).to_string())
|
||||
.filter(|user| !user.is_empty())
|
||||
}
|
||||
|
||||
@@ -819,6 +819,14 @@ mod tests {
|
||||
user_from_destination("palav@example.com").as_deref(),
|
||||
Some("palav")
|
||||
);
|
||||
assert_eq!(
|
||||
user_from_destination("ssh://palav@example.com:2222/srv/app").as_deref(),
|
||||
Some("palav")
|
||||
);
|
||||
assert_eq!(
|
||||
user_from_destination("ssh://palav@[2001:db8::2]:2222/srv/app").as_deref(),
|
||||
Some("palav")
|
||||
);
|
||||
assert_eq!(destination_host("palav@example.com"), "example.com");
|
||||
assert_eq!(destination_host("example.com:2222"), "example.com");
|
||||
assert_eq!(destination_host("palav@[2001:db8::1]:2222"), "2001:db8::1");
|
||||
|
||||
Reference in New Issue
Block a user