Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): bump hosted-git-info from 6.0.0 to 6.1.1 #700

Merged
merged 2 commits into from
Nov 8, 2022

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Oct 31, 2022

Bumps hosted-git-info from 6.0.0 to 6.1.1.

Release notes

Sourced from hosted-git-info's releases.

v6.1.1

6.1.1 (2022-10-27)

Bug Fixes

v6.1.0

6.1.0 (2022-10-26)

Features

Changelog

Sourced from hosted-git-info's changelog.

6.1.1 (2022-10-27)

Bug Fixes

6.1.0 (2022-10-26)

Features

Commits
  • 31cdc8d chore: release 6.1.1
  • f03bfbd fix: only correct protocols when called from githost
  • 306e817 chore: release 6.1.0
  • a44bd35 feat: add separate static method for just parsing urls
  • cb7cbc2 chore: @​npmcli/template-oss@​4.7.1
  • 7024fa4 chore: postinstall for dependabot template-oss PR
  • 304ed88 chore: bump @​npmcli/template-oss from 4.5.1 to 4.6.1
  • b372b14 chore: bump @​npmcli/eslint-config from 3.1.0 to 4.0.0
  • See full diff in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 6.0.0 to 6.1.1.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/main/CHANGELOG.md)
- [Commits](npm/hosted-git-info@v6.0.0...v6.1.1)

---
updated-dependencies:
- dependency-name: hosted-git-info
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot added dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Oct 31, 2022
@ybiquitous ybiquitous self-assigned this Nov 8, 2022
@ybiquitous ybiquitous changed the title chore(deps): bump hosted-git-info from 6.0.0 to 6.1.1 fix(deps): bump hosted-git-info from 6.0.0 to 6.1.1 Nov 8, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2022

npm diff --diff=hosted-git-info@6.0.0 --diff=hosted-git-info@6.1.1 --diff-unified=2
diff --git a/lib/from-url.js b/lib/from-url.js
index v6.0.0..v6.1.1 100644
--- a/lib/from-url.js
+++ b/lib/from-url.js
@@ -1,44 +1,6 @@
 'use strict'
 
-const url = require('url')
+const parseUrl = require('./parse-url')
 
-const safeUrl = (u) => {
-  try {
-    return new url.URL(u)
-  } catch {
-    // this fn should never throw
-  }
-}
-
-const lastIndexOfBefore = (str, char, beforeChar) => {
-  const startPosition = str.indexOf(beforeChar)
-  return str.lastIndexOf(char, startPosition > -1 ? startPosition : Infinity)
-}
-
-// accepts input like git:github.com:user/repo and inserts the // after the first :
-const correctProtocol = (arg, protocols) => {
-  const firstColon = arg.indexOf(':')
-  const proto = arg.slice(0, firstColon + 1)
-  if (Object.prototype.hasOwnProperty.call(protocols, proto)) {
-    return arg
-  }
-
-  const firstAt = arg.indexOf('@')
-  if (firstAt > -1) {
-    if (firstAt > firstColon) {
-      return `git+ssh://${arg}`
-    } else {
-      return arg
-    }
-  }
-
-  const doubleSlash = arg.indexOf('//')
-  if (doubleSlash === firstColon + 1) {
-    return arg
-  }
-
-  return `${arg.slice(0, firstColon + 1)}//${arg.slice(firstColon + 1)}`
-}
-
 // look for github shorthand inputs, such as npm/cli
 const isGitHubShorthand = (arg) => {
@@ -72,38 +34,4 @@
 }
 
-// attempt to correct an scp style url so that it will parse with `new URL()`
-const correctUrl = (giturl) => {
-  // ignore @ that come after the first hash since the denotes the start
-  // of a committish which can contain @ characters
-  const firstAt = lastIndexOfBefore(giturl, '@', '#')
-  // ignore colons that come after the hash since that could include colons such as:
-  // git@github.com:user/package-2#semver:^1.0.0
-  const lastColonBeforeHash = lastIndexOfBefore(giturl, ':', '#')
-
-  if (lastColonBeforeHash > firstAt) {
-    // the last : comes after the first @ (or there is no @)
-    // like it would in:
-    // proto://hostname.com:user/repo
-    // username@hostname.com:user/repo
-    // :password@hostname.com:user/repo
-    // username:password@hostname.com:user/repo
-    // proto://username@hostname.com:user/repo
-    // proto://:password@hostname.com:user/repo
-    // proto://username:password@hostname.com:user/repo
-    // then we replace the last : with a / to create a valid path
-    giturl = giturl.slice(0, lastColonBeforeHash) + '/' + giturl.slice(lastColonBeforeHash + 1)
-  }
-
-  if (lastIndexOfBefore(giturl, ':', '#') === -1 && giturl.indexOf('//') === -1) {
-    // we have no : at all
-    // as it would be in:
-    // username@hostname.com/user/repo
-    // then we prepend a protocol
-    giturl = `git+ssh://${giturl}`
-  }
-
-  return giturl
-}
-
 module.exports = (giturl, opts, { gitHosts, protocols }) => {
   if (!giturl) {
@@ -111,8 +39,6 @@
   }
 
-  const correctedUrl = isGitHubShorthand(giturl)
-    ? `github:${giturl}`
-    : correctProtocol(giturl, protocols)
-  const parsed = safeUrl(correctedUrl) || safeUrl(correctUrl(correctedUrl))
+  const correctedUrl = isGitHubShorthand(giturl) ? `github:${giturl}` : giturl
+  const parsed = parseUrl(correctedUrl, protocols)
   if (!parsed) {
     return
diff --git a/lib/index.js b/lib/index.js
index v6.0.0..v6.1.1 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -4,4 +4,5 @@
 const hosts = require('./hosts.js')
 const fromUrl = require('./from-url.js')
+const parseUrl = require('./parse-url.js')
 
 const cache = new LRU({ max: 1000 })
@@ -56,4 +57,8 @@
   }
 
+  static parseUrl (url) {
+    return parseUrl(url)
+  }
+
   #fill (template, opts) {
     if (typeof template !== 'function') {
diff --git a/package.json b/package.json
index v6.0.0..v6.1.1 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
 {
   "name": "hosted-git-info",
-  "version": "6.0.0",
+  "version": "6.1.1",
   "description": "Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab",
   "main": "./lib/index.js",
@@ -34,6 +34,6 @@
   },
   "devDependencies": {
-    "@npmcli/eslint-config": "^3.0.1",
-    "@npmcli/template-oss": "4.5.1",
+    "@npmcli/eslint-config": "^4.0.0",
+    "@npmcli/template-oss": "4.7.1",
     "tap": "^16.0.1"
   },
@@ -55,5 +55,5 @@
   "templateOSS": {
     "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
-    "version": "4.5.1"
+    "version": "4.7.1"
   }
 }
diff --git a/lib/parse-url.js b/lib/parse-url.js
new file mode 100644
index v6.0.0..v6.1.1 
--- a/lib/parse-url.js
+++ b/lib/parse-url.js
@@ -0,0 +1,78 @@
+const url = require('url')
+
+const lastIndexOfBefore = (str, char, beforeChar) => {
+  const startPosition = str.indexOf(beforeChar)
+  return str.lastIndexOf(char, startPosition > -1 ? startPosition : Infinity)
+}
+
+const safeUrl = (u) => {
+  try {
+    return new url.URL(u)
+  } catch {
+    // this fn should never throw
+  }
+}
+
+// accepts input like git:github.com:user/repo and inserts the // after the first :
+const correctProtocol = (arg, protocols) => {
+  const firstColon = arg.indexOf(':')
+  const proto = arg.slice(0, firstColon + 1)
+  if (Object.prototype.hasOwnProperty.call(protocols, proto)) {
+    return arg
+  }
+
+  const firstAt = arg.indexOf('@')
+  if (firstAt > -1) {
+    if (firstAt > firstColon) {
+      return `git+ssh://${arg}`
+    } else {
+      return arg
+    }
+  }
+
+  const doubleSlash = arg.indexOf('//')
+  if (doubleSlash === firstColon + 1) {
+    return arg
+  }
+
+  return `${arg.slice(0, firstColon + 1)}//${arg.slice(firstColon + 1)}`
+}
+
+// attempt to correct an scp style url so that it will parse with `new URL()`
+const correctUrl = (giturl) => {
+  // ignore @ that come after the first hash since the denotes the start
+  // of a committish which can contain @ characters
+  const firstAt = lastIndexOfBefore(giturl, '@', '#')
+  // ignore colons that come after the hash since that could include colons such as:
+  // git@github.com:user/package-2#semver:^1.0.0
+  const lastColonBeforeHash = lastIndexOfBefore(giturl, ':', '#')
+
+  if (lastColonBeforeHash > firstAt) {
+    // the last : comes after the first @ (or there is no @)
+    // like it would in:
+    // proto://hostname.com:user/repo
+    // username@hostname.com:user/repo
+    // :password@hostname.com:user/repo
+    // username:password@hostname.com:user/repo
+    // proto://username@hostname.com:user/repo
+    // proto://:password@hostname.com:user/repo
+    // proto://username:password@hostname.com:user/repo
+    // then we replace the last : with a / to create a valid path
+    giturl = giturl.slice(0, lastColonBeforeHash) + '/' + giturl.slice(lastColonBeforeHash + 1)
+  }
+
+  if (lastIndexOfBefore(giturl, ':', '#') === -1 && giturl.indexOf('//') === -1) {
+    // we have no : at all
+    // as it would be in:
+    // username@hostname.com/user/repo
+    // then we prepend a protocol
+    giturl = `git+ssh://${giturl}`
+  }
+
+  return giturl
+}
+
+module.exports = (giturl, protocols) => {
+  const withProtocol = protocols ? correctProtocol(giturl, protocols) : giturl
+  return safeUrl(withProtocol) || safeUrl(correctUrl(withProtocol))
+}
  • Size: 25.7 KB → 26.0 KB (+270 B)
  • Files: 6 → 7 (+1)

Posted by ybiquitous/npm-diff-action v1.3.5 (Node.js v18.12.0; npm v8.19.3)

@ybiquitous ybiquitous merged commit d86ffbc into main Nov 8, 2022
@ybiquitous ybiquitous deleted the dependabot/npm_and_yarn/hosted-git-info-6.1.1 branch November 8, 2022 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant