aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-17 12:05:52 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-17 12:05:52 +0800
commit5c80236c0ed27af9db42b6d5b60f0d365457c7a4 (patch)
tree4e2dfa054eb0e04aeba99130af18b3c5e85ac104
parentmisc.go: Remove environ_to_map as unused (diff)
downloadforge-5c80236c0ed27af9db42b6d5b60f0d365457c7a4.tar.gz
forge-5c80236c0ed27af9db42b6d5b60f0d365457c7a4.tar.zst
forge-5c80236c0ed27af9db42b6d5b60f0d365457c7a4.zip
{remote_url,ssh_server}.go: Use path.Join instead of trimming and adding
-rw-r--r--remote_url.go6
-rw-r--r--ssh_server.go3
2 files changed, 5 insertions, 4 deletions
diff --git a/remote_url.go b/remote_url.go
index f64d6ec..28d7dbe 100644
--- a/remote_url.go
+++ b/remote_url.go
@@ -2,13 +2,13 @@ package main
import (
"net/url"
- "strings"
+ "path"
)
func generate_ssh_remote_url(group_name, repo_name string) string {
- return strings.TrimSuffix(config.SSH.Root, "/") + "/" + url.PathEscape(group_name) + "/:/repos/" + url.PathEscape(repo_name)
+ return path.Join(config.SSH.Root, url.PathEscape(group_name), "/:/repos/", url.PathEscape(repo_name))
}
func generate_http_remote_url(group_name, repo_name string) string {
- return strings.TrimSuffix(config.HTTP.Root, "/") + "/" + url.PathEscape(group_name) + "/:/repos/" + url.PathEscape(repo_name)
+ return path.Join(config.HTTP.Root, url.PathEscape(group_name), "/:/repos/", url.PathEscape(repo_name))
}
diff --git a/ssh_server.go b/ssh_server.go
index 206bf72..63ba467 100644
--- a/ssh_server.go
+++ b/ssh_server.go
@@ -4,6 +4,7 @@ import (
"fmt"
"net"
"os"
+ "path"
"strings"
glider_ssh "github.com/gliderlabs/ssh"
@@ -41,7 +42,7 @@ func serve_ssh(listener net.Listener) error {
}
clog.Info("Incoming SSH: " + session.RemoteAddr().String() + " " + client_public_key_string + " " + session.RawCommand())
- fmt.Fprintln(session.Stderr(), "Lindenii Forge "+VERSION+", source at "+strings.TrimSuffix(config.HTTP.Root, "/")+"/:/source/\r")
+ fmt.Fprintln(session.Stderr(), "Lindenii Forge "+VERSION+", source at "+path.Join(config.HTTP.Root, "/:/source/\r"))
cmd := session.Command()