Socket
Socket
Sign inDemoInstall

hosted-git-info

Package Overview
Dependencies
0
Maintainers
3
Versions
64
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 2.3.0

2

git-host-info.js

@@ -56,3 +56,3 @@ 'use strict'

'pathtemplate': '{user}/{project}{#committish}',
'pathmatch': /^[/]([^/]+)[/]([^/]+?)(?:[.]git)?$/
'pathmatch': /^[/]([^/]+)[/]([^/]+?)(?:[.]git|[/])?$/
}

@@ -59,0 +59,0 @@

@@ -32,27 +32,33 @@ 'use strict'

var parsed = parseGitUrl(url)
var shortcutMatch = url.match(new RegExp('^([^:]+):([^/]+)[/](.+)$'))
var matches = Object.keys(gitHosts).map(function (gitHostName) {
var gitHostInfo = gitHosts[gitHostName]
var auth = null
if (parsed.auth && authProtocols[parsed.protocol]) {
auth = decodeURIComponent(parsed.auth)
try {
var gitHostInfo = gitHosts[gitHostName]
var auth = null
if (parsed.auth && authProtocols[parsed.protocol]) {
auth = decodeURIComponent(parsed.auth)
}
var committish = parsed.hash ? decodeURIComponent(parsed.hash.substr(1)) : null
var user = null
var project = null
var defaultRepresentation = null
if (shortcutMatch && shortcutMatch[1] === gitHostName) {
user = decodeURIComponent(shortcutMatch[2])
project = decodeURIComponent(shortcutMatch[3])
defaultRepresentation = 'shortcut'
} else {
if (parsed.host !== gitHostInfo.domain) return
if (!gitHostInfo.protocols_re.test(parsed.protocol)) return
if (!parsed.path) return
var pathmatch = gitHostInfo.pathmatch
var matched = parsed.path.match(pathmatch)
if (!matched) return
if (matched[1] != null) user = decodeURIComponent(matched[1])
if (matched[2] != null) project = decodeURIComponent(matched[2])
defaultRepresentation = protocolToRepresentation(parsed.protocol)
}
return new GitHost(gitHostName, user, auth, project, committish, defaultRepresentation)
} catch (ex) {
if (!(ex instanceof URIError)) throw ex
}
var committish = parsed.hash ? decodeURIComponent(parsed.hash.substr(1)) : null
var user = null
var project = null
var defaultRepresentation = null
if (parsed.protocol === gitHostName + ':') {
user = decodeURIComponent(parsed.host)
project = parsed.path && decodeURIComponent(parsed.path.replace(/^[/](.*?)(?:[.]git)?$/, '$1'))
defaultRepresentation = 'shortcut'
} else {
if (parsed.host !== gitHostInfo.domain) return
if (!gitHostInfo.protocols_re.test(parsed.protocol)) return
var pathmatch = gitHostInfo.pathmatch
var matched = parsed.path.match(pathmatch)
if (!matched) return
if (matched[1] != null) user = decodeURIComponent(matched[1])
if (matched[2] != null) project = decodeURIComponent(matched[2])
defaultRepresentation = protocolToRepresentation(parsed.protocol)
}
return new GitHost(gitHostName, user, auth, project, committish, defaultRepresentation)
}).filter(function (gitHostInfo) { return gitHostInfo })

@@ -59,0 +65,0 @@ if (matches.length !== 1) return

{
"name": "hosted-git-info",
"version": "2.2.0",
"version": "2.3.0",
"description": "Provides metadata and conversions from repository urls for Github, Bitbucket and Gitlab",

@@ -28,3 +28,8 @@ "main": "index.js",

"tap": "^10.0.2"
}
},
"files": [
"index.js",
"git-host.js",
"git-host-info.js"
]
}

@@ -35,4 +35,22 @@ # hosted-git-info

And methods of:
## Version Contract
The major version will be bumped any time…
* The constructor stops accepting URLs that it previously accepted.
* A method is removed.
* A method no longer accepts the number and type of arguments it previously accepted.
* A method can return a different type than it currently returns.
Implications:
* I do not consider the specific format of the urls returned from, say
`.https()` to be a part of the contract. The contract is that it will
return a string that can be used to fetch the repo via HTTPS. But what
that string looks like, specifically, can change.
* Dropping support for a hosted git provider would constitute a breaking
change.
## Methods
* info.file(path)

@@ -39,0 +57,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc