File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 11var _ = require ( 'lodash' ) ,
2- ipcheck = require ( 'ipcheck' ) ;
2+ ipcheck = require ( 'ipcheck' ) ,
3+ bufferEquals = require ( './lib/bufferequals' ) ;
34
45var conditions = {
56 NumericEquals : function NumericEquals ( a , b ) {
@@ -58,11 +59,11 @@ var conditions = {
5859 } ,
5960 BinaryEquals : function BinaryEquals ( a , b ) {
6061 if ( ! _ . isString ( b ) || ! ( a instanceof Buffer ) ) return false ;
61- return a . equals ( new Buffer ( b , 'base64' ) ) ;
62+ return bufferEquals ( a , new Buffer ( b , 'base64' ) ) ;
6263 } ,
6364 BinaryNotEquals : function BinaryEquals ( a , b ) {
6465 if ( ! _ . isString ( b ) || ! ( a instanceof Buffer ) ) return false ;
65- return ! a . equals ( new Buffer ( b , 'base64' ) ) ;
66+ return ! bufferEquals ( a , new Buffer ( b , 'base64' ) ) ;
6667 } ,
6768 /*
6869 ArnEquals
Original file line number Diff line number Diff line change 1+ module . exports = function ( a , b ) {
2+ if ( ! Buffer . isBuffer ( a ) || ! Buffer . isBuffer ( b ) ) return false ;
3+ if ( typeof a . equals === 'function' ) return a . equals ( b ) ;
4+ if ( a === b ) return true ;
5+ if ( a . length !== b . length ) return false ;
6+ for ( var i = 0 ; i < a . length ; i ++ ) {
7+ if ( a [ i ] !== b [ i ] ) return false ;
8+ }
9+ return true ;
10+ } ;
You can’t perform that action at this time.
0 commit comments