node-restify icon indicating copy to clipboard operation
node-restify copied to clipboard

Bugfix

Open carlosascari opened this issue 5 years ago • 0 comments

When using the conditionalHandler plugin, if a single version route has a contentType, but the other routes do not, it will crash as it tries to call .join on a undefined contentType field.

See for yourself:

const restify = require('restify');

const server = restify.createServer();

server.get('/', restify.plugins.conditionalHandler([
  {
    contentType: ['application/json'],
    version: '1.5.0', 
    handler: (req, res, next) => {
      res.json({
        version: 0
      })
    }
  },
  {
    // contentType is missing here
    version: '1.1.0', 
    handler: (req, res, next) => {
      res.json({
        version: 1
      })
    }
  }
]));

Pre-Submission Checklist

  • [ ] Opened an issue discussing these changes before opening the PR
  • [ ] Ran the linter and tests via make prepush
  • [ ] Included comprehensive and convincing tests for changes

Issues

Closes:

  • Issue #
  • Issue #
  • Issue #

Summarize the issues that discussed these changes

Changes

What does this PR do?

carlosascari avatar Jun 24 '19 16:06 carlosascari