Skip to content

Instantly share code, notes, and snippets.

@jollytoad
Created December 4, 2012 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jollytoad/4201882 to your computer and use it in GitHub Desktop.
Save jollytoad/4201882 to your computer and use it in GitHub Desktop.
Parse a data URI
function parseDataUri(uri) {
var m = /^data:([^;,/]+\/[^;,/]+)?(;charset=([^;,]+))?(;base64)?,(.*)$/.exec(uri);
return m && {
type: m[1] || "text/plain",
charset: m[3],
base64: !!m[4],
data: m[5]
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment