Handle empty path
This commit is contained in:
parent
e173f4d002
commit
49c7ad61df
|
@ -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:]
|
||||
|
||||
|
|
Loading…
Reference in New Issue