go-chi / go-chi/chi

Regex param doesn't match dots

Open
#758 6 comments 0 reactions 0 assignees View on GitHub
v6
Dominant language
Go
Stars
22.8k
Forks
1.2k
Avg merge
5h 17m
Merged PRs (30d)
10

Description

Example program:
```go
package main

import (
"fmt"
"net/http"
"net/http/httptest"

"github.com/go-chi/chi/v5"
)

func main() {
mux := chi.NewMux()
mux.Get("/{param:.+}.json", func(w http.ResponseWriter, r *http.Request) {
param := chi.URLParam(r, "param")
_, _ = fmt.Fprintf(w, "param=%s", param)
})

rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/param.json", nil)
mux.ServeHTTP(rec, req)

fmt.Printf("code: %d, body: %s\n", rec.Code, rec.Body)

rec = httptest.NewRecorder()
req = httptest.NewRequest(http.MethodGet, "/param.with.dots.json", nil)
mux.ServeHTTP(rec, req)

fmt.Printf("code: %d, body: %s\n", rec.Code, rec.Body)
}
```

Expected:
```
code: 200, body: param=param
code: 404, body: param=param.with.dots
```

Got:
```
code: 200, body: param=param
code: 404, body: 404 page not found
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.