Skip to content

Commit

Permalink
default req.proxy destination to req.uri if not provided (common case)
Browse files Browse the repository at this point in the history
  • Loading branch information
davehorton committed Aug 2, 2017
1 parent 33fb3a4 commit 56079cf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ class Request extends Emitter {
if( this.source !== 'network' ) {
throw new Error('Request#proxy can only be used for incoming requests') ;
}
if( typeof opts !== 'object' || !opts.destination ) {
throw new Error('Request#proxy: opts.destination is required') ;
}
opts = opts || {} ;

//TODO: throw error if req.res.send has already been called (i.e. can't start off as UAS and then become a proxy)
let destination = opts.destination;
let destination = opts.destination || this.uri ;
if( typeof destination === 'string') { opts.destination = [destination] ; }

Object.assign( opts, {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drachtio",
"version": "3.0.2",
"version": "3.0.4",
"description": "node.js middleware for sip applications",
"keywords": [
"framework",
Expand Down

0 comments on commit 56079cf

Please sign in to comment.