0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-06-22 03:37:48 +02:00

use url.ParseGitURL for IsSSHURL

This commit is contained in:
pomidorry 2026-05-17 20:10:16 +03:00
parent f60c4097bd
commit 1b48b9866f

View File

@ -6,17 +6,18 @@ package ssh
import (
"context"
"fmt"
"strings"
"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
giturl "code.gitea.io/gitea/modules/git/url"
"code.gitea.io/gitea/modules/log"
)
// IsSSHURL checks if a URL is an SSH URL
func IsSSHURL(url string) bool {
return strings.HasPrefix(url, "ssh://")
func IsSSHURL(remote string) bool {
u, err := giturl.ParseGitURL(remote)
return err == nil && u.Scheme == "ssh"
}
// GetOrCreateSSHKeypairForUser gets or creates an SSH keypair for the given user