npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hutson/parse-repository-url

v5.0.0

Published

Parse repository URLs to extract, SCM platform, domain, user, and project information.

Downloads

10,085,501

Readme

@hutson/parse-repository-url

Parse repository URLs to extract, SCM platform, domain, user, and project information.

Occasionally you need to take a Git repository URL, such as https://gitlab.com/gitlab-org/gitlab-ce and extract the user/group and project name from the URL for use in other tools and processes.

@hutson/parse-repository-url helps to extract that information from many valid Git URLs strings that you might encounter, including for platforms like GitLab, GitHub, and their various use cases, such as hosted, on-premise, and multiple sub-groups.

Table of Contents

Features

  • [x] Return browse function that returns URL usable in a browser. (Similar to hosted-git-info)
  • [x] Return domain property containing the fully qualified domain name and port.
  • [x] Return project property.
  • [x] Return type property indicating the SCM host, such as github or gitlab.
  • [x] Return user property.

*Note: Returns null for any property where the information could not be extracted from the repository URL.

Installation

To install the @hutson/parse-repository-url tool for use in your project's publish process please run the following command:

yarn add [--dev] @hutson/parse-repository-url

Usage

const parseRepositoryURL = require(`@hutson/parse-repository-url`);

/*{
  browse: [Function],
  domain: 'github.com',
  project: 'project',
  type: 'github',
  user: 'user'
}*/
parseRepositoryURL(`https://github.com/user/project`);

/*{
  browse: [Function],
  domain: 'git.example.com',
  project: 'project',
  type: null,
  user: 'user'
}*/
parseRepositoryURL(`https://git.example.com/user/project`);

/*{
  browse: [Function],
  domain: 'github.com',
  project: 'project',
  type: 'github',
  user: 'user'
}*/
parseRepositoryURL(`[email protected]:user/project`);

/*{
  browse: [Function],
  domain: 'somewhere',
  project: null,
  type: null,
  user: null
}*/
parseRepositoryURL(`https://somewhere`);

Check out the index.spec.js file under the src/ directory for a full list of URLs that can be parsed for GitLab, GitHub, including hosted, on-premise, and multiple sub-groups.

Security Disclosure Policy

To report a security vulnerability in this package, or one of it's dependencies, please use the Tidelift security contact page. Tidelift will coordinate the process to address the vulnerability and disclose the incident to our users.

Enterprise Support

Available as part of the Tidelift Subscription.

The maintainers of @hutson/parse-repository-url and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Debugging

To assist users of @hutson/parse-repository-url with debugging the behavior of this module we use the debug utility package to print information about the publish process to the console. To enable debug message printing, the environment variable DEBUG, which is the variable used by the debug package, must be set to a value configured by the package containing the debug messages to be printed.

To print debug messages on a unix system set the environment variable DEBUG with the name of this package prior to executing @hutson/parse-repository-url:

DEBUG=@hutson/parse-repository-url [CONSUMING TOOL]

On the Windows command line you may do:

set DEBUG=@hutson/parse-repository-url
[CONSUMING TOOL]

Node Support Policy

We only support Long-Term Support versions of Node.

We specifically limit our support to LTS versions of Node, not because this package won't work on other versions, but because we have a limited amount of time, and supporting LTS offers the greatest return on that investment.

It's possible this package will work correctly on newer versions of Node. It may even be possible to use this package on older versions of Node, though that's more unlikely as we'll make every effort to take advantage of features available in the oldest LTS version we support.

As each Node LTS version reaches its end-of-life we will remove that version from the node engines property of our package's package.json file. Removing a Node version is considered a breaking change and will entail the publishing of a new major version of this package. We will not accept any requests to support an end-of-life version of Node. Any merge requests or issues supporting an end-of-life version of Node will be closed.

We will accept code that allows this package to run on newer, non-LTS, versions of Node. Furthermore, we will attempt to ensure our own changes work on the latest version of Node. To help in that commitment, our continuous integration setup runs against all LTS versions of Node in addition the most recent Node release; called current.

JavaScript package managers should allow you to install this package with any version of Node, with, at most, a warning if your version of Node does not fall within the range specified by our node engines property. If you encounter issues installing this package, please report the issue to your package manager.

Contributing

Please read our contributing guide to see how you may contribute to this project.