{"action":"created","issue":{"url":"https://api.github.com/repos/expressjs/express/issues/2985","repository_url":"https://api.github.com/repos/expressjs/express","labels_url":"https://api.github.com/repos/expressjs/express/issues/2985/labels{/name}","comments_url":"https://api.github.com/repos/expressjs/express/issues/2985/comments","events_url":"https://api.github.com/repos/expressjs/express/issues/2985/events","html_url":"https://github.com/expressjs/express/issues/2985","id":152984885,"number":2985,"title":"Using next() in regex based GET handler calls POST handler with same endpoint","user":{"login":"psych0der","id":928501,"avatar_url":"https://avatars.githubusercontent.com/u/928501?v=3","gravatar_id":"","url":"https://api.github.com/users/psych0der","html_url":"https://github.com/psych0der","followers_url":"https://api.github.com/users/psych0der/followers","following_url":"https://api.github.com/users/psych0der/following{/other_user}","gists_url":"https://api.github.com/users/psych0der/gists{/gist_id}","starred_url":"https://api.github.com/users/psych0der/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/psych0der/subscriptions","organizations_url":"https://api.github.com/users/psych0der/orgs","repos_url":"https://api.github.com/users/psych0der/repos","events_url":"https://api.github.com/users/psych0der/events{/privacy}","received_events_url":"https://api.github.com/users/psych0der/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-04T11:01:33Z","updated_at":"2016-05-04T12:27:46Z","closed_at":"2016-05-04T12:27:46Z","body":"Example:\r\n\r\nMiddleware for some get requests\r\n```js\r\napp.get('/init/*', function (req, res, next) {\r\n // do something\r\n console.log('GET middleware called');\r\n next();\r\n})\r\n```\r\n\r\nwhich is followed by:\r\n\r\n```js\r\napp.post('/init/*', function (req, res, next) {\r\n // do something else\r\n console.log('POST middleware called');\r\n next();\r\n})\r\n```\r\n\r\nand\r\n\r\n```js\r\napp.get('/init/', function (req, res) {\r\n console.log('GET handler called');\r\n return res.json({'status':'success'})\r\n})\r\n```\r\n\r\nWhen the user hits the server using GET  at `/` , both the middlewares get called.\r\n\r\nIdeally calling next() from GET handlers should only call other GET handler in the chain, rather than any other handler with the same mounting point.\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/expressjs/express/issues/comments/216844685","html_url":"https://github.com/expressjs/express/issues/2985#issuecomment-216844685","issue_url":"https://api.github.com/repos/expressjs/express/issues/2985","id":216844685,"user":{"login":"dougwilson","id":67512,"avatar_url":"https://avatars.githubusercontent.com/u/67512?v=3","gravatar_id":"","url":"https://api.github.com/users/dougwilson","html_url":"https://github.com/dougwilson","followers_url":"https://api.github.com/users/dougwilson/followers","following_url":"https://api.github.com/users/dougwilson/following{/other_user}","gists_url":"https://api.github.com/users/dougwilson/gists{/gist_id}","starred_url":"https://api.github.com/users/dougwilson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dougwilson/subscriptions","organizations_url":"https://api.github.com/users/dougwilson/orgs","repos_url":"https://api.github.com/users/dougwilson/repos","events_url":"https://api.github.com/users/dougwilson/events{/privacy}","received_events_url":"https://api.github.com/users/dougwilson/received_events","type":"User","site_admin":false},"created_at":"2016-05-04T12:27:45Z","updated_at":"2016-05-04T12:27:45Z","body":"Hi @psych0der, thanks for the update! You are missing many of the pieces of the information I asked for, and with the updated routes, I still cannot reproduce the issue. I'm going to close this issue for now as not reproducible. If you can provide all the following information I can re-open, though!\r\n\r\n1. The version of Node.js you are using.\r\n2. The version of this module you are using.\r\n3. A mini Express app that has all the code needed to reproduce the error (just like I did above). This will help make sure that we are using exactly the same code to remove as much variables as possible between our tests.\r\n4. The exact call we need to make the Express app.\r\n5. A description of what we should see if it is not working as expected vs working as expected.\r\n\r\nHere is my debugging session with the updated routes and new call:\r\n```\r\n$ npm i express\r\nexpress@4.13.4 node_modules\\express\r\n├── escape-html@1.0.3\r\n├── array-flatten@1.1.1\r\n├── merge-descriptors@1.0.1\r\n├── methods@1.1.2\r\n├── cookie-signature@1.0.6\r\n├── range-parser@1.0.3\r\n├── fresh@0.3.0\r\n├── etag@1.7.0\r\n├── parseurl@1.3.1\r\n├── vary@1.0.1\r\n├── path-to-regexp@0.1.7\r\n├── content-disposition@0.5.1\r\n├── utils-merge@1.0.0\r\n├── cookie@0.1.5\r\n├── content-type@1.0.1\r\n├── serve-static@1.10.2\r\n├── depd@1.1.0\r\n├── qs@4.0.0\r\n├── on-finished@2.3.0 (ee-first@1.1.1)\r\n├── finalhandler@0.4.1 (unpipe@1.0.0)\r\n├── debug@2.2.0 (ms@0.7.1)\r\n├── proxy-addr@1.0.10 (forwarded@0.1.0, ipaddr.js@1.0.5)\r\n├── type-is@1.6.12 (media-typer@0.3.0, mime-types@2.1.11)\r\n├── accepts@1.2.13 (negotiator@0.5.3, mime-types@2.1.11)\r\n└── send@0.13.1 (destroy@1.0.4, statuses@1.2.1, ms@0.7.1, mime@1.3.4, http-errors@1.3.1)\r\n\r\n$ cat app.js\r\nvar express = require('express');\r\nvar app = express();\r\n\r\napp.get('/v1/*', function (req, res, next) {\r\n // do something\r\n console.log('GET middleware called');\r\n next();\r\n});\r\n\r\napp.post('/v1/*', function (req, res, next) {\r\n // do something else\r\n console.log('POST middleware called');\r\n next();\r\n});\r\n\r\napp.get('/v1/init/', function (req, res) {\r\n console.log('GET handler called');\r\n return res.json({'status':'success'})\r\n});\r\n\r\napp.listen(3000);\r\n\r\n$ node app.js &\r\n[1] 4352\r\n\r\n$ curl http://127.0.0.1:3000/v1/init\r\nGET middleware called\r\nGET handler called\r\n{\"status\":\"success\"}\r\n```\r\n\r\nAs you can see, the POST middleware is not being called, as I would expect and as you are expecting as well."}}