这是indexloc提供的服务,不要输入任何密码
Skip to content

fetch() does not set MIME type in .blob() response #722

@Throvn

Description

@Throvn

When using fetch, the content type of the blob is not set. As an example you can run the sample below.
b.type is going to be an empty string.

fetch('https://picsum.photos/200')
        .then(res => res.blob())
        .then(b => {
            console.log('Content type:', b.type);
        })
        .catch(console.error)

That's because in the fetch polyfill (/src/js/polyfills/fetch/body.js) the blob is not set with the type option.

The fix would be to just take the Content-Type header value and set it as the type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions