{"size": 934, "ext": "js", "max_stars_repo_path": "node_modules/rest-facade/src/URL.js", "max_stars_repo_name": "ksubramani9/MachineLoaning", "max_stars_repo_stars_event_min_datetime": "2018-03-13T12:14:16.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-20T06:01:24.000Z", "max_issues_repo_path": "node_modules/rest-facade/src/URL.js", "max_issues_repo_name": "ksubramani9/MachineLoaning", "max_issues_repo_issues_event_min_datetime": "2017-12-06T11:31:58.000Z", "max_issues_repo_issues_event_max_datetime": "2018-03-02T03:09:00.000Z", "max_forks_repo_path": "node_modules/rest-facade/src/URL.js", "max_forks_repo_name": "ksubramani9/MachineLoaning", "max_forks_repo_forks_event_min_datetime": "2017-12-28T04:43:24.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-23T09:09:42.000Z"}
{"max_stars_count": 4, "max_issues_count": 2, "max_forks_count": 14, "avg_line_length": 19.8723404255, "max_line_length": 74, "alphanum_fraction": 0.6092077088}
var extend = require('util')._extend;


/**
 * @class URL
 * Utility class for formatting URLs.
 */
var URL = function(url, params) {
  this.url = url;
  this.params = params;
};


/**
 * Format the URL as a string.
 *
 * @return {string}   The formatted URL including the querystring.
 */
URL.prototype.toString = function() {
  var url = this.url;

  // If there are no params, simply return the base URL.
  if (typeof params  !== 'object') return url;

  // Replace all the :params with the actual value.
  for (var key in params) {
    if (url.indexOf(':' + key) > -1) {
      url = url.replace(':' + key, params[key]);
      delete params[key];
    }
  }

  // Remove all the remainign :params which weren't replaced by any value.
  url = url.replace(/\/:[^\/]+/g, '');

  // Add the querystring,
  var querystring = Object.keys(params).map(function (key) {
    return key + '=' +
  })


  return url;
};


module.exports = URL;
