@@ -61,6 +61,13 @@ describe('proxyaddr(req, trust)', function () {
6161 assert . doesNotThrow ( proxyaddr . bind ( null , req , [ 'loopback' , '10.0.0.1' ] ) ) ;
6262 } ) ;
6363
64+ it ( 'should not alter input array' , function ( ) {
65+ var arr = [ 'loopback' , '10.0.0.1' ] ;
66+ var req = createReq ( '127.0.0.1' ) ;
67+ assert . doesNotThrow ( proxyaddr . bind ( null , req , arr ) ) ;
68+ assert . deepEqual ( arr , [ 'loopback' , '10.0.0.1' ] ) ;
69+ } ) ;
70+
6471 it ( 'should reject non-IP' , function ( ) {
6572 var req = createReq ( '127.0.0.1' ) ;
6673 assert . throws ( proxyaddr . bind ( null , req , 'blargh' ) , / i n v a l i d I P a d d r e s s / ) ;
@@ -481,6 +488,12 @@ describe('proxyaddr.compile(trust)', function () {
481488 assert . throws ( proxyaddr . compile . bind ( null , '::ffff:a00:2/136' ) , / i n v a l i d r a n g e o n a d d r e s s / ) ;
482489 assert . throws ( proxyaddr . compile . bind ( null , '::ffff:a00:2/-46' ) , / i n v a l i d r a n g e o n a d d r e s s / ) ;
483490 } ) ;
491+
492+ it ( 'should not alter input array' , function ( ) {
493+ var arr = [ 'loopback' , '10.0.0.1' ] ;
494+ assert . equal ( typeof proxyaddr . compile ( arr ) , 'function' ) ;
495+ assert . deepEqual ( arr , [ 'loopback' , '10.0.0.1' ] ) ;
496+ } ) ;
484497 } ) ;
485498 } ) ;
486499} ) ;
0 commit comments