diff --git a/dist/commonjs.js b/dist/commonjs.js index 6614091..b05247d 100644 --- a/dist/commonjs.js +++ b/dist/commonjs.js @@ -47,7 +47,7 @@ module.exports = function (repoUrl, opts) { if (!hostname) { return null } if (hostname !== 'github.com' && hostname !== 'www.github.com' && !opts.enterprise) { return null } - var parts = pathname.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\w-_\.\/]+)?(\/blob\/[\w-_\.\/]+)?/) + var parts = pathname.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\%\w-_\.\/]+)?(\/blob\/[\%\w-_\.\/]+)?/) // ([\w-_\.]+) if (!parts) { return null } obj.user = parts[1] @@ -59,9 +59,11 @@ module.exports = function (repoUrl, opts) { obj.branch = 'master' obj.path = parts[3].replace(/\/$/, '') } else if (parts[3]) { - obj.branch = parts[3].replace(/^\/tree\//, '').match(/[\w-_.]+\/{0,1}[\w-_]+/)[0] + var branchMatch = parts[3].replace(/^\/tree\//, '').match(/[\%\w-_.]*\/?[\%\w-_]+/) + obj.branch = branchMatch && branchMatch[0] } else if (parts[4]) { - obj.branch = parts[4].replace(/^\/blob\//, '').match(/[\w-_.]+\/{0,1}[\w-_]+/)[0] + var branchMatch = parts[4].replace(/^\/blob\//, '').match(/[\%\w-_.]*\/?[\%\w-_]+/) + obj.branch = branchMatch && branchMatch[0] } else { obj.branch = 'master' } diff --git a/dist/gh.js b/dist/gh.js index 82ca8bb..0c76bc1 100644 --- a/dist/gh.js +++ b/dist/gh.js @@ -48,7 +48,7 @@ module.exports = function (repoUrl, opts) { if (!hostname) { return null } if (hostname !== 'github.com' && hostname !== 'www.github.com' && !opts.enterprise) { return null } - var parts = pathname.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\w-_\.\/]+)?(\/blob\/[\w-_\.\/]+)?/) + var parts = pathname.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\%\w-_\.\/]+)?(\/blob\/[\%\w-_\.\/]+)?/) // ([\w-_\.]+) if (!parts) { return null } obj.user = parts[1] @@ -60,9 +60,11 @@ module.exports = function (repoUrl, opts) { obj.branch = 'master' obj.path = parts[3].replace(/\/$/, '') } else if (parts[3]) { - obj.branch = parts[3].replace(/^\/tree\//, '').match(/[\w-_.]+\/{0,1}[\w-_]+/)[0] + var branchMatch = parts[3].replace(/^\/tree\//, '').match(/[\%\w-_.]*\/?[\%\w-_]+/) + obj.branch = branchMatch && branchMatch[0] } else if (parts[4]) { - obj.branch = parts[4].replace(/^\/blob\//, '').match(/[\w-_.]+\/{0,1}[\w-_]+/)[0] + var branchMatch = parts[4].replace(/^\/blob\//, '').match(/[\%\w-_.]*\/?[\%\w-_]+/) + obj.branch = branchMatch && branchMatch[0] } else { obj.branch = 'master' }