Skip to content

Commit

Permalink
fix byte-range-stream so it adheres to the HTTP standard
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfagun74 committed Jun 16, 2024
1 parent 6b6b84d commit 4e1c542
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/modules/files/models/byte-range-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ export default class ByteRangeStream extends Transform {
) {
const chunkSize = BigInt(chunk.length);
if (
this.bytesRead + chunkSize >= this.startByte &&
this.bytesRead < this.endByte
this.bytesRead + chunkSize > this.startByte &&
this.bytesRead <= this.endByte
) {
const start = Number(
this.startByte > this.bytesRead ? this.startByte - this.bytesRead : 0n,
);
const end = Number(
this.endByte > this.bytesRead + chunkSize
this.endByte >= this.bytesRead + chunkSize - 1n
? chunkSize
: this.endByte - this.bytesRead,
: this.endByte - this.bytesRead + 1n,
);
this.push(chunk.subarray(start, end));
}
Expand Down

0 comments on commit 4e1c542

Please sign in to comment.