File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const originalSocketSend = Socket.prototype.send;
1111class Scope {
1212 public _done : boolean ;
1313 public address ?: string ;
14- public buffer ?: string | readonly any [ ] | ArrayBufferLike ;
14+ public buffer ?: ArrayBuffer | SharedArrayBuffer | NodeJS . TypedArray | string | readonly any [ ] ;
1515 public length ?: number ;
1616 public offset ?: number ;
1717 public port ?: number ;
@@ -74,17 +74,18 @@ function overriddenSocketSend(
7474 const length = hasLengthAndOffset ? ( lengthOrAddressOrCallback as number ) || 0 : 0 ;
7575 const offset = hasLengthAndOffset ? ( offsetOrPortOrCallback as number ) : 0 ;
7676 const port = hasLengthAndOffset ? ( portOrCallback as number ) : ( offsetOrPortOrCallback as number ) ;
77- const message = ArrayBuffer . isView ( msg ) ? msg . buffer : msg ;
77+ const msgLength = msg instanceof DataView ? msg . byteLength : msg . length ;
7878
79- if ( offset >= message . slice . length ) {
79+ if ( offset >= msgLength ) {
8080 throw new Error ( 'Offset into buffer too large.' ) ;
8181 }
8282
83- if ( offset + length > message . slice . length ) {
83+ if ( offset + length > msgLength ) {
8484 throw new Error ( 'Offset + length beyond buffer length.' ) ;
8585 }
8686
87- const newBuffer = message . slice ( offset , offset + length ) ;
87+ const newBuffer =
88+ msg instanceof DataView ? msg . buffer . slice ( offset , offset + length ) : msg . slice ( offset , offset + length ) ;
8889 const host = `${ address } :${ port } ` ;
8990
9091 if ( intercepts . hasOwnProperty ( host ) ) {
You can’t perform that action at this time.
0 commit comments