go-chi / go-chi/chi

there may be a issue with one of the tests in mux_test

Open
#636 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

routing
Dominant language
Go
Stars
22.9k
Forks
1.4k
Avg merge
5h 17m
Merged PRs (30d)
10

Description

in mux_test.go#L1469

1 func TestMuxRegexp2(t *testing.T) {
2	r := NewRouter()
3	r.Get("/foo-{suffix:[a-z]{2,3}}.json", func(w http.ResponseWriter, r *http.Request) {
4		w.Write([]byte(URLParam(r, "suffix")))
5	})
6	ts := httptest.NewServer(r)
7	defer ts.Close()
8
9	if _, body := testRequest(t, ts, "GET", "/foo-.json", nil); body != "" {
10		t.Fatalf(body)
11	}
12	if _, body := testRequest(t, ts, "GET", "/foo-abc.json", nil); body != "abc" {
13		t.Fatalf(body)
14	}
15}

I don't think the /foo-.json in line 9 matches the /foo-{suffix:[a-z]{2,3}}.json in line 3.
because "" does not satisfy [a-z]{2,3}.or what is the original purpose of this design.
this question is similar to #609.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with TestMuxRegexp2 in mux_test.go around line 1469 and run that test to observe the /foo-.json and /foo-abc.json cases. Read the related discussion in issue #609 and the router matching behavior; done means the test's expected behavior and its intended regexp semantics are resolved, with the test or issue clarified accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.