Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Apr 4, 2019
1 parent 54fa22f commit 42bed3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// <reference types="node" />

class MimeBuffer extends Buffer {
type:string
typeFull:string
charset:string
type: string;
typeFull: string;
charset: string;
}

declare function dataUriToBuffer(uri: string): MimeBuffer;
Expand Down
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ module.exports = dataUriToBuffer;
* @api public
*/

function dataUriToBuffer (uri) {
function dataUriToBuffer(uri) {
if (!/^data\:/i.test(uri)) {
throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');
throw new TypeError(
'`uri` does not appear to be a Data URI (must begin with "data:")'
);
}

// strip newlines
uri = uri.replace(/\r?\n/g, '');

// split the URI up into the "metadata" and the "data" portions
var firstComma = uri.indexOf(',');
if (-1 === firstComma || firstComma <= 4) throw new TypeError('malformed data: URI');
if (-1 === firstComma || firstComma <= 4) {
throw new TypeError('malformed data: URI');
}

// remove the "data:" scheme and parse the metadata
var meta = uri.substring(5, firstComma).split(';');
Expand Down

0 comments on commit 42bed3a

Please sign in to comment.