diff --git a/server.go b/server.go index 5a1e8a2..5922052 100644 --- a/server.go +++ b/server.go @@ -156,11 +156,8 @@ func handleConn(conn *tls.Conn, baseURL, title, home_message string) { return } - // skip first '/' - path = path[1:] - // home - if path == "" { + if path == "" || path == "/" { _, err = fmt.Fprintf(conn, "20 text/gemini\r\n# " + title + "\n\n" + home_message) if err != nil { log.Println("send error: %s", err) @@ -170,7 +167,7 @@ func handleConn(conn *tls.Conn, baseURL, title, home_message string) { } // profile - if strings.HasPrefix(path, "profile/") { + if strings.HasPrefix(path, "/profile/") { // skip prefix path = path[8:] _, err = strconv.ParseUint(path, 10, 64) @@ -187,7 +184,7 @@ func handleConn(conn *tls.Conn, baseURL, title, home_message string) { log.Println("Received request for account " + path) printProfile(conn, baseURL, path) - } /* thread */ else if strings.HasPrefix(path, "thread/") { + } /* thread */ else if strings.HasPrefix(path, "/thread/") { // skip prefix path = path[7:]