url: function()

in assets/app/models/Github.js [37:57]


  url: function (opts) {
    opts = opts || {};
    var ghUrl = 'https://api.github.com',
        route = opts.route || 'repos',
        owner = opts.owner || this.owner,
        repository = opts.repository || this.name,
        baseUrl = [ghUrl, route],
        qs = $.param(_.extend({
          access_token: this.token,
          ref: this.branch
        }, opts.params || {}));

    if (opts.method) baseUrl.push(opts.method);
    else if (opts.root) baseUrl.push(owner, repository);
    else baseUrl.push(owner, repository, 'contents');

    if (opts.path) baseUrl.push(opts.path);
    else if (this.file) baseUrl.push(this.file);

    return [baseUrl.join('/'), qs].join('?');
  },