Accept the configured relay path with or without its trailing slash while using the normalized URL for authentication.
- commit
- 7af5c4e52eb604207ac4190a4e1fefb9ceae639e
- parent
- 38542ac80a3fd2937c52da111948ce2bbabbacbc
- author
- Dami <dami.etoile@gmail.com>
| M | tinyrelay/ | 2 | +- |
| M | tinyrelay/ | 4 | ++-- |
@@ -117,7 +117,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
117117 w.Header().Set("Access-Control-Allow-Origin", "*")118118 w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type")119119 w.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS")120- if r.URL.Path != "/" && r.URL.Path != s.relayPath && r.URL.Path != "/healthz" && r.URL.Path != "/readyz" {120+ if r.URL.Path != "/" && strings.TrimSuffix(r.URL.Path, "/") != s.relayPath && r.URL.Path != "/healthz" && r.URL.Path != "/readyz" {121121 http.NotFound(w, r)122122 return123123 }@@ -28,12 +28,12 @@ func TestStandaloneCloseDrainsWebSockets(t *testing.T) {
2828 }2929 3030 func TestStandaloneServerRoutesAndClose(t *testing.T) {31- s, err := tinyrelay.OpenServer(context.Background(), tinyrelay.ServerConfig{DataDir: t.TempDir(), PublicURL: "https://relay.example/nostr"})31+ s, err := tinyrelay.OpenServer(context.Background(), tinyrelay.ServerConfig{DataDir: t.TempDir(), PublicURL: "https://relay.example/nostr/"})3232 if err != nil {3333 t.Fatal(err)3434 }3535 defer s.Close()36- for _, path := range []string{"/", "/nostr", "/healthz", "/readyz"} {36+ for _, path := range []string{"/", "/nostr", "/nostr/", "/healthz", "/readyz"} {3737 response := httptest.NewRecorder()3838 s.ServeHTTP(response, httptest.NewRequest(http.MethodGet, path, nil))3939 if response.Code != http.StatusOK {