{"size": 506, "ext": "js", "max_stars_repo_path": "node_modules/parse-data-uri/index.js", "max_stars_repo_name": "josh-soutar/jmdb", "max_stars_repo_stars_event_min_datetime": "2018-09-13T16:26:30.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-05T15:00:38.000Z", "max_issues_repo_path": "node_modules/parse-data-uri/index.js", "max_issues_repo_name": "josh-soutar/jmdb", "max_issues_repo_issues_event_min_datetime": "2021-03-10T07:46:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T23:42:15.000Z", "max_forks_repo_path": "node_modules/parse-data-uri/index.js", "max_forks_repo_name": "josh-soutar/jmdb", "max_forks_repo_forks_event_min_datetime": "2021-11-17T13:22:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T16:27:33.000Z"}
{"max_stars_count": 4, "max_issues_count": 8, "max_forks_count": 6, "avg_line_length": 19.4615384615, "max_line_length": 56, "alphanum_fraction": 0.6719367589}
var toBuffer = require('data-uri-to-buffer')

function parseDataUri (dataUri) {

  return {
    mimeType: normalizeMimeType(parseMimeType(dataUri)),
    data: toBuffer(dataUri)
  }
}

function parseMimeType(uri) {
  return uri.substring(5, uri.indexOf(';'))
}

var prefix = /^(\w+\/)+/
function normalizeMimeType(mime) {
  mime = mime.toLowerCase()
  var once = mime.match(prefix)
  if (!once || !(once = once[1])) {
    return mime
  }
  return mime.replace(prefix, once)

}

module.exports = parseDataUri