Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit

* chore: bump @npmcli/template-oss from 4.13.0 to 4.14.1

Bumps [@npmcli/template-oss]( from 4.13.0 to 4.14.1.
- [Release notes](
- [Changelog](
- [Commits](npm/template-oss@v4.13.0...v4.14.1)

- dependency-name: "@npmcli/template-oss"
  dependency-type: direct:development
  update-type: version-update:semver-minor

Signed-off-by: dependabot[bot] <>

* chore: postinstall for dependabot template-oss PR

* chore: postinstall for dependabot template-oss PR


Signed-off-by: dependabot[bot] <>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]>
Co-authored-by: npm CLI robot <>
Co-authored-by: nlf <>

Git stats


Failed to load latest commit information.
Latest commit message
Commit time


This will let you identify and transform various git hosts URLs between protocols. It also can tell you what the URL is for the raw path for particular file for direct access without git.


const hostedGitInfo = require("hosted-git-info")
const info = hostedGitInfo.fromUrl("", opts)
/* info looks like:
  type: "github",
  domain: "",
  user: "npm",
  project: "hosted-git-info"

If the URL can't be matched with a git host, null will be returned. We can match git, ssh and https urls. Additionally, we can match ssh connect strings ( and shortcuts (eg, github:npm/hosted-git-info). GitHub specifically, is detected in the case of a third, unprefixed, form: npm/hosted-git-info.

If it does match, the returned object has properties of:

  • info.type -- The short name of the service
  • info.domain -- The domain for git protocol use
  • info.user -- The name of the user/org on the git host
  • info.project -- The name of the project on the git host

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 can no longer accept the number and type of arguments it previously accepted.
  • A method can return a different type than it currently returns.


  • 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.


const info = hostedGitInfo.fromUrl(gitSpecifier[, options])

  • gitSpecifer is a URL of a git repository or a SCP-style specifier of one.
  • options is an optional object. It can have the following properties:
    • noCommittish — If true then committishes won't be included in generated URLs.
    • noGitPlus — If true then git+ won't be prefixed on URLs.


All of the methods take the same options as the fromUrl factory. Options provided to a method override those provided to the constructor.

  • info.file(path, opts)

Given the path of a file relative to the repository, returns a URL for directly fetching it from the githost. If no committish was set then HEAD will be used as the default.

For example hostedGitInfo.fromUrl("").file("package.json") would return

  • info.shortcut(opts)

eg, github:npm/hosted-git-info

  • info.browse(path, fragment, opts)


  • info.bugs(opts)




  • info.https(opts)

eg, git+

  • info.sshurl(opts)

eg, git+ssh://

  • info.ssh(opts)


  • info.path(opts)

eg, npm/hosted-git-info

  • info.tarball(opts)


  • info.getDefaultRepresentation()

Returns the default output type. The default output type is based on the string you passed in to be parsed

  • info.toString(opts)

Uses the getDefaultRepresentation to call one of the other methods to get a URL for this resource. As such hostedGitInfo.fromUrl(url).toString() will give you a normalized version of the URL that still uses the same protocol.

Shortcuts will still be returned as shortcuts, but the special case github form of org/project will be normalized to github:org/project.

SSH connect strings will be normalized into git+ssh URLs.

Supported hosts

Currently this supports GitHub (including Gists), Bitbucket, GitLab and Sourcehut. Pull requests for additional hosts welcome.