{"action":"reopened","issue":{"url":"https://api.github.com/repos/gorilla/mux/issues/62","labels_url":"https://api.github.com/repos/gorilla/mux/issues/62/labels{/name}","comments_url":"https://api.github.com/repos/gorilla/mux/issues/62/comments","events_url":"https://api.github.com/repos/gorilla/mux/issues/62/events","html_url":"https://github.com/gorilla/mux/issues/62","id":37659134,"number":62,"title":"URL variables bug for multiple patterns with relatively complex regexp","user":{"login":"xdmnl","id":1101732,"avatar_url":"https://avatars.githubusercontent.com/u/1101732?v=3","gravatar_id":"","url":"https://api.github.com/users/xdmnl","html_url":"https://github.com/xdmnl","followers_url":"https://api.github.com/users/xdmnl/followers","following_url":"https://api.github.com/users/xdmnl/following{/other_user}","gists_url":"https://api.github.com/users/xdmnl/gists{/gist_id}","starred_url":"https://api.github.com/users/xdmnl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xdmnl/subscriptions","organizations_url":"https://api.github.com/users/xdmnl/orgs","repos_url":"https://api.github.com/users/xdmnl/repos","events_url":"https://api.github.com/users/xdmnl/events{/privacy}","received_events_url":"https://api.github.com/users/xdmnl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2014-07-11T13:19:31Z","updated_at":"2015-08-07T03:31:06Z","closed_at":null,"body":"Hi,\r\n\r\nThere's a bug with URL variable with a relatively complex regexp.\r\nFor example, let's take the regexp `a|(b/c)` which should match `a` or `b/c`.\r\n\r\nIf I use the regexp in a path with one pattern, it works. You can test it with these routeTests:\r\n\r\n    tests := []routeTest{\r\n      {\r\n        title:       \"Path route with single pattern with pipe, match\",\r\n        route:       new(Route).Path(\"/{category:a|(b/c)}\"),\r\n        request:     newRequest(\"GET\", \"http://localhost/a\"),\r\n        vars:        map[string]string{\"category\": \"a\"},\r\n        host:        \"\",\r\n        path:        \"/a\",\r\n        shouldMatch: true,\r\n      },\r\n      {\r\n        title:       \"Path route with single pattern with pipe, match\",\r\n        route:       new(Route).Path(\"/{category:a|(b/c)}\"),\r\n        request:     newRequest(\"GET\", \"http://localhost/b/c\"),\r\n        vars:        map[string]string{\"category\": \"b/c\"},\r\n        host:        \"\",\r\n        path:        \"/b/c\",\r\n        shouldMatch: true,\r\n      },\r\n    }\r\n\r\nBut if I try to use it in a path with multiple patterns, it produces weird results.\r\n\r\nThis test...\r\n\r\n    tests := []routeTest{\r\n      {\r\n        title:       \"Path route with multiple patterns with pipe, match\",\r\n        route:       new(Route).Path(\"/{category:a|(b/c)}/{product}/{id:[0-9]+}\"),\r\n        request:     newRequest(\"GET\", \"http://localhost/a/product_name/1\"),\r\n        vars:        map[string]string{\"category\": \"a\", \"product\": \"product_name\", \"id\": \"1\"},\r\n        host:        \"\",\r\n        path:        \"/a/product_name/1\",\r\n        shouldMatch: true,\r\n      },\r\n    }\r\n...fails because the variables don't match:\r\n\r\n    $ go test\r\n    --- FAIL: TestPath (0.00 seconds)\r\n        mux_test.go:810: (Path route with multiple patterns with pipe, match) Vars not equal:\r\n        expected map[category:a product:product_name id:1],\r\n        got      map[category:a product: id:product_name]\r\n\r\nAnd this test...\r\n\r\n    tests := []routeTest{\r\n      {\r\n        title:       \"Path route with multiple patterns with pipe, match\",\r\n        route:       new(Route).Path(\"/{category:a|(b/c)}/{product}/{id:[0-9]+}\"),\r\n        request:     newRequest(\"GET\", \"http://localhost/b/c/product_name/1\"),\r\n        vars:        map[string]string{\"category\": \"b/c\", \"product\": \"product_name\", \"id\": \"1\"},\r\n        host:        \"\",\r\n        path:        \"/b/c/product_name/1\",\r\n        shouldMatch: true,\r\n      },\r\n    }\r\n...also fails because the variables don't match either (but in a different way):\r\n\r\n    $ go test\r\n    --- FAIL: TestPath (0.00 seconds)\r\n        mux_test.go:810: (Path route with multiple patterns with pipe, match) Vars not equal:\r\n        expected map[category:b/c product:product_name id:1],\r\n        got      map[category:b/c product:b/c id:product_name]\r\n\r\nEDIT: Fix manual editing mistakes (category_name instead of product_name)"}}