Skip to content

readAsDataUrl from Blob with type: 'text/plain' should return a dataurl with base64 encoding #2269

@sarod

Description

@sarod

Basic info:

  • Node.js version: 8.11.1
  • jsdom version: 11.10.0

Minimal reproduction case

const { JSDOM } = require("jsdom");

const dom = new JSDOM();

const dom = new JSDOM();
const Blob = dom.window.Blob;
const FileReader = dom.window.FileReader;


const textBlob = new Blob(['What is the meaning of life the universe and everything?'], { type: 'text/plain' });
const reader = new FileReader();
reader.onload = (event) => {
   const dataUrl = reader.result;
   console.log( dataUrl);
};
reader.readAsDataURL(textBlob);

This logs:

data:text/plain;charset=undefined,What%20is%20the%20meaning%20of%20life%20the%20universe%20and%20everything%3F

How does similar code behave in browsers?

Similar code in all the browser I tested (Firefox, Chrome, Edge, Safari) returns base64 encoded dataurl:

data:text/plain;base64,V2hhdCBpcyB0aGUgbWVhbmluZyBvZiBsaWZlIHRoZSB1bml2ZXJzZSBhbmQgZXZlcnl0aGluZz8=

Jsbin: http://jsbin.com/yaverumosi/edit?html,js,console,output

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