imrefazekas / connect-rest

Exceptionally featureful Restful web services middleware for connect node.js
MIT License
100 stars 29 forks source link

Setting context via options doesn't work if context is blank #4

Closed Steve-OH closed 11 years ago

Steve-OH commented 11 years ago

When calling rest.rester(), if you set the value of options.context to a blank string, or leave it out of the options object altogether, the internal context is set to '/api'. So:

rest.rester({context: ""});  // context is set to '/api'

rest.rester({logger: "connect-rest"});  // context is set to '/api'

This works, however:

rest.context('');  // context is set to ''

The problem occurs on line 209 of connect-rest.js:

exports.context( options.context || '/api' );

I'd submit a pull request except that I can't figure out what the intent of that code is. ;-)

-Steve

imrefazekas commented 11 years ago

Very right. Thank you. That line aimed to test if value is given or not. Did not check empty string. It is fixed now, thanks again.