Exemple #1
0
/**
 * Process a Data URI Image and Saves to Google Cloud Storage.
 *
 * @param {string} url Data URI image URL to process
 * @param {string} destFile name of the destination file
 * @return {Promise<url[]>} URLs for the new images in Google Cloud Storage
 */
function dataUriAndSave(url, destFile) {
  const buffer = strongDataUri.decode(url);
  const contentType = buffer.mimetype;
  const bufferStream = new stream.PassThrough();
  bufferStream.end(buffer);
  return this.saveImages(bufferStream, destFile, contentType);
}
NetworkAgent.prototype.loadResourceForFrontend = function(params, done) {
  if (/^data:/.test(params.url)) {
    try {
      done(null, {
        statusCode: 200,
        headers: {},
        content: dataUri.decode(params.url).toString('ascii')
      });
    } catch (err) {
      done(err);
    }
    return;
  }

  loadFileResource(params, done);
};
    value: function(inspectorScriptData) {
      // Source maps have some issues in different libraries.
      // If source map exposed in inline mode, we can easy fix some potential issues.
      var sourceMapUrl = inspectorScriptData.sourceMapURL;
      if (!sourceMapUrl) return;

      var sourceMap;
      try {
        sourceMap = dataUri.decode(sourceMapUrl).toString();
      } catch (err) {
        return;
      }

      sourceMap = JSON.parse(sourceMap.toString());
      this._checkSourceMapIssues(inspectorScriptData, sourceMap);
      sourceMap = JSON.stringify(sourceMap);

      inspectorScriptData.sourceMapURL = dataUri.encode(sourceMap, 'application/json');
    }