Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

The slicing method in the buffer.Blob is wrong according to the spec #37335

Copy link
Copy link
@jimmywarting

Description

@jimmywarting
Issue body actions
  • Version: v15.8.0
  • Platform: Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:11 PDT 2020; root:xnu-7195.50.7~2/RELEASE_X86_64 x86_64
  • Subsystem:

Thought I would try it out and help you find some quirks before making it stable. The slicing method is wrong

What steps will reproduce the bug?

import { Blob } from 'buffer'

new Blob().slice(0, 500)
new Blob(['abc']).slice(-1).text()        // c
new Blob(['abc']).slice(0, -1).text()     // ab
new Blob(['abcdef']).slice(-3, -1).text() // de

How often does it reproduce?

Happens everytime

What is the expected behavior?

...to get a new Blob slice without throwing any error.
the slicing method should behave similar like you slice a String or a ArrayBuffer

But internally it can be more complicated then that if it should operate on multiple blob parts that are async (see #37338)

What do you see instead?

Uncaught:
RangeError [ERR_OUT_OF_RANGE]: The value of "end" is out of range.
It must be less than or equal to length. Received 500

This should not happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.