hosted-git-info
Advanced tools
Comparing version 1.1.0 to 1.2.0
31
index.js
@@ -5,8 +5,12 @@ "use strict" | ||
var GitHost = exports = module.exports = function (type, user, project, comittish) { | ||
this.type = type | ||
this.domain = gitHosts[type].domain | ||
this.filetemplate = gitHosts[type].filetemplate | ||
this.user = user | ||
this.project = project | ||
this.comittish = comittish | ||
this.type = type | ||
this.domain = gitHosts[type].domain | ||
this.filetemplate = gitHosts[type].filetemplate | ||
this.sshtemplate = gitHosts[type].sshtemplate | ||
this.sshurltemplate = gitHosts[type].sshurltemplate | ||
this.browsetemplate = gitHosts[type].browsetemplate | ||
this.httpstemplate = gitHosts[type].httpstemplate | ||
this.user = user | ||
this.project = project | ||
this.comittish = comittish | ||
} | ||
@@ -61,7 +65,9 @@ GitHost.prototype = {} | ||
"protocols": [ "git+ssh", "git+https", "ssh", "https" ], | ||
"domain": "bitbucket.org" | ||
"domain": "bitbucket.org", | ||
"browsetemplate": "https://bitbucket.org/{user}/{project}/overview" | ||
}, | ||
gitlab: { | ||
"protocols": [ "git+ssh", "git+https", "ssh", "https" ], | ||
"domain": "gitlab.com" | ||
"domain": "gitlab.com", | ||
"browsetemplate": "https://gitlab.com/{user}/{project}" | ||
} | ||
@@ -93,4 +99,4 @@ } | ||
Object.keys(this).forEach(function(K){ if (self[K]!=null && vars[K]==null) vars[K] = self[K] }) | ||
Object.keys(vars).forEach(function(K){ vars[K] = encodeURIComponent(vars[K]) }) | ||
vars["#comittish"] = vars.comittish ? "#" + vars.comittish : "" | ||
Object.keys(vars).forEach(function(K){ (K[0]!='#') && (vars[K] = encodeURIComponent(vars[K])) }) | ||
var res = template | ||
@@ -113,2 +119,9 @@ Object.keys(vars).forEach(function(K){ | ||
GitHost.prototype.browse = function () { | ||
var browsetemplate = this.browsetemplate || "https://{domain}/{user}/{project}{#/comittish}" | ||
return this._fill(browsetemplate, { | ||
"#/comittish": this.comittish ? "/tree/" + this.comittish : "" | ||
}) | ||
} | ||
GitHost.prototype.https = function () { | ||
@@ -115,0 +128,0 @@ var httpstemplate = this.httpstemplate || "https://{domain}/{user}/{project}.git{#comittish}" |
{ | ||
"name": "hosted-git-info", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -48,2 +48,6 @@ # hosted-git-info | ||
* info.browse() | ||
eg, `https://github.com/npm/hosted-git-info/tree/v1.2.0` | ||
* info.https() | ||
@@ -50,0 +54,0 @@ |
@@ -12,2 +12,3 @@ "use strict" | ||
t.is( hostinfo.https().toLowerCase(), "https://bitbucket.org/a/b.git" + hash, label + " -> https" ) | ||
t.is( hostinfo.browse().toLowerCase(), "https://bitbucket.org/a/b/overview", label + " -> browse" ) | ||
t.is( hostinfo.ssh().toLowerCase(), "git@bitbucket.org:a/b.git" + hash, label + " -> ssh" ) | ||
@@ -14,0 +15,0 @@ t.is( hostinfo.sshurl().toLowerCase(), "git+ssh://git@bitbucket.org/a/b.git" + hash, label + " -> sshurl" ) |
@@ -13,2 +13,3 @@ "use strict" | ||
t.is( hostinfo.https().toLowerCase(), "https://github.com/a/b.git" + hash, label + " -> https" ) | ||
t.is( hostinfo.browse().toLowerCase(), "https://github.com/a/b" + (branch ? "/tree/" + branch : ""), label + " -> browse" ) | ||
t.is( hostinfo.ssh().toLowerCase(), "git@github.com:a/b.git" + hash, label + " -> ssh" ) | ||
@@ -15,0 +16,0 @@ t.is( hostinfo.sshurl().toLowerCase(), "git+ssh://git@github.com/a/b.git" + hash, label + " -> sshurl" ) |
@@ -13,2 +13,3 @@ "use strict" | ||
t.is( hostinfo.https().toLowerCase(), "https://gitlab.com/a/b.git" + hash, label + " -> https" ) | ||
t.is( hostinfo.browse().toLowerCase(), "https://gitlab.com/a/b", label + " -> browse" ) | ||
t.is( hostinfo.ssh().toLowerCase(), "git@gitlab.com:a/b.git" + hash, label + " -> ssh" ) | ||
@@ -15,0 +16,0 @@ t.is( hostinfo.sshurl().toLowerCase(), "git+ssh://git@gitlab.com/a/b.git" + hash, label + " -> sshurl" ) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13887
214
73