{"size": 571, "ext": "js", "max_stars_repo_path": "node_modules/gatsby-source-datocms/src/hooks/sourceNodes/createTypes/utils/createUrl.js", "max_stars_repo_name": "asimitree/datocms-gatsby-portfolio-website-demo", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/gatsby-source-datocms/src/hooks/sourceNodes/createTypes/utils/createUrl.js", "max_issues_repo_name": "asimitree/datocms-gatsby-portfolio-website-demo", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/gatsby-source-datocms/src/hooks/sourceNodes/createTypes/utils/createUrl.js", "max_forks_repo_name": "asimitree/datocms-gatsby-portfolio-website-demo", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.55, "max_line_length": 72, "alphanum_fraction": 0.6007005254}
const { decamelizeKeys } = require('humps');
const objectAssign = require('object-assign');
const queryString = require('query-string');

module.exports = (image, base = {}, extra = {}, autoFormat = false) => {
  const mergedParams = decamelizeKeys(objectAssign({}, base, extra), {
    separator: '-',
  });

  if (autoFormat) {
    const auto = (mergedParams.auto || '').split(',');
    mergedParams.auto = auto
      .filter(a => !!a && a !== 'format')
      .concat(['format'])
      .join(',');
  }

  return `${image.url}?${queryString.stringify(mergedParams)}`;
};
