diff --git a/zqd/handlers_test.go b/zqd/handlers_test.go index 15f1e797cf..2b9272845a 100644 --- a/zqd/handlers_test.go +++ b/zqd/handlers_test.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "net/http" "net/http/httptest" + "net/url" "os" "path/filepath" "strings" @@ -182,6 +183,22 @@ func TestSpaceDelete(t *testing.T) { }) } +func TestURLEncodingSupport(t *testing.T) { + c := newCore(t) + defer os.RemoveAll(c.Root) + + rawSpace := "raw %<>space.brim" + encodedSpaceURL := fmt.Sprintf("http://localhost:9867/space/%s", url.PathEscape(rawSpace)) + + createSpace(t, c, rawSpace, "") + + res := httpRequest(t, zqd.NewHandler(c), "GET", encodedSpaceURL, nil) + require.Equal(t, http.StatusOK, res.StatusCode) + + res = httpRequest(t, zqd.NewHandler(c), "DELETE", encodedSpaceURL, nil) + require.Equal(t, http.StatusNoContent, res.StatusCode) +} + func TestNoEndSlashSupport(t *testing.T) { c := newCore(t) defer os.RemoveAll(c.Root) diff --git a/zqd/server.go b/zqd/server.go index aad13a1b04..5344c5c1a9 100644 --- a/zqd/server.go +++ b/zqd/server.go @@ -35,7 +35,6 @@ var Version VersionMessage func NewHandler(root *Core) http.Handler { r := mux.NewRouter() - r = r.UseEncodedPath() r.Handle("/space", wrapRoot(root, handleSpaceList)).Methods("GET") r.Handle("/space", wrapRoot(root, handleSpacePost)).Methods("POST") r.Handle("/space/{space}", wrapRoot(root, handleSpaceGet)).Methods("GET")