/**
 * parse-github-short-url <https://github.com/tunnckoCore/parse-github-short-url>
 *
 * Copyright (c) 2014-2015 Charlike Mike Reagent, contributors.
 * Released under the MIT license.
 */

'use strict';

var regex = require('github-short-url-regex');

/**
 * Parse github short url to object
 *
 * **Example:**
 *
 * ```js
 * var parseGithubShortUrl = require('parse-github-short-url');
 * parseGithubShortUrl('tunnckoCore/glob2fp#master');
 * //=> {
 * //  user: 'tunnckoCore',
 * //  username: 'tunnckoCore',
 * //  org: 'tunnckoCore',
 * //  organization: 'tunnckoCore',
 * //  repo: 'glob2fp',
 * //  repository: 'glob2fp',
 * //  branch: 'master'
 * //};
 * ```
 *
 * @name parseGithubShortUrl
 * @param  {String} `<str>` string to parse for `user/repo#branch`
 * @param  {Object} `[opts]` options are passed to [github-short-url-regex][github-short-url-regex]
 * @return {Object}
 * @api public
 */
module.exports = function parseGithubShortUrl(str, opts) {
  if (!str) {
    throw new Error('parse-github-short-url: should have at least 1 arguments');
  }

  if (typeof str !== 'string') {
    throw new TypeError('parse-github-short-url: expect `str` be string');
  }

  opts = opts || {exact: false};

  if (regex(opts).test(str)) {
    str = regex(opts).exec(str);

    return {
      user: RegExp.$1,
      username: RegExp.$1,
      org: RegExp.$1,
      organization: RegExp.$1,
      repo: RegExp.$2,
      repository: RegExp.$2,
      branch: RegExp.$3
    };
  }

  return {
    user: '',
    username: '',
    org: '',
    organization: '',
    repo: '',
    repository: '',
    branch: ''
  };
};

@@ -1208,16 +1208,35 @@
 alse%7D;%0A%0A
+  var match = %5B%5D;%0A%0A
   if (re
@@ -1266,14 +1266,26 @@
     
-str = 
+match = str.match(
 rege
@@ -1295,23 +1295,16 @@
 pts)
-.exec(str
 );%0A
-%0A
   
+%7D%0A%0A
   re
@@ -1312,238 +1312,129 @@
 urn 
-%7B%0A      user: RegExp.$1,%0A      username: RegExp.$1,%0A      org: RegExp.$1,%0A      organization: RegExp.$1,%0A      repo: RegExp.$2,%0A      repository: RegExp.$2,%0A      branch: RegExp.$3%0A    %7D;%0A  %7D%0A%0A  return %7B%0A    user: '',%0A    
+new ParseGithubShorthand(match);%0A%7D;%0A%0Afunction ParseGithubShorthand(match) %7B%0A  this.user = match%5B1%5D %7C%7C '';%0A  this.
 username
 : ''
@@ -1433,31 +1433,63 @@
 name
-: '',%0A    org: '',%0A    
+ = match%5B1%5D %7C%7C '';%0A  this.org = match%5B1%5D %7C%7C '';%0A  this.
 orga
@@ -1500,32 +1500,64 @@
 tion
-: '',%0A    repo: '',%0A    
+ = match%5B1%5D %7C%7C '';%0A  this.repo = match%5B2%5D %7C%7C '';%0A  this.
 repo
@@ -1566,33 +1566,73 @@
 tory
-: '',%0A    
+ = match%5B2%5D %7C%7C '';%0A  this.
 branch
-:
+ = match%5B3%5D %7C%7C
  ''
+;%0A
 %0A  
-%7D
+return this
 ;%0A%7D
-;
 %0A

return class instead of just object