Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@hutson/parse-repository-url
Advanced tools
Parse repository URLs to extract, SCM platform, domain, user, and project information.
@hutson/parse-repository-url is an npm package designed to parse repository URLs into their component parts. This can be useful for extracting information such as the repository type, user, and project name from a given URL.
Parse repository URL
This feature allows you to parse a repository URL and extract its components. The code sample demonstrates how to use the package to parse a GitHub repository URL and log the parsed components.
const parseRepositoryUrl = require('@hutson/parse-repository-url');
const repoUrl = 'https://github.com/hutson/parse-repository-url';
const parsed = parseRepositoryUrl(repoUrl);
console.log(parsed);
Handle different repository URL formats
This feature demonstrates the package's ability to handle different repository URL formats, such as SSH URLs. The code sample shows how to parse an SSH URL and log the parsed components.
const parseRepositoryUrl = require('@hutson/parse-repository-url');
const repoUrl = 'git+ssh://git@github.com:hutson/parse-repository-url.git';
const parsed = parseRepositoryUrl(repoUrl);
console.log(parsed);
The 'parse-github-url' package is designed specifically for parsing GitHub URLs. It extracts information such as the user, repository name, and branch. Compared to @hutson/parse-repository-url, it is more specialized for GitHub URLs and may not support other repository types.
The 'git-url-parse' package is a more general-purpose tool for parsing Git URLs. It supports a wide range of Git URL formats and provides detailed information about the repository. Compared to @hutson/parse-repository-url, it offers broader support for different Git hosting services and URL formats.
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.
browse
function that returns URL usable in a browser. (Similar to hosted-git-info
)domain
property containing the fully qualified domain name and port.project
property.type
property indicating the SCM host, such as github
or gitlab
.user
property.*Note: Returns
null
for any property where the information could not be extracted from the repository URL.
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
const parseRepositoryURL = require(`@hutson/parse-github-repository`);
// {domain: `gitlab.com`, project: `parse-repository-url`, type: `gitlab`, user: `hyper-expanse/open-source`}
parseRepositoryURL(`https://gitlab.com/hyper-expanse/open-source/parse-repository-url`);
// {domain: `git.example.com`, project: `parse-repository-url`, type: null, user: `hyper-expanse/open-source`}
parseRepositoryURL(`https://git.example.com/hyper-expanse/open-source/parse-repository-url`);
// {domain: `gitlab.com`, project: `parse-repository-url`, type: `gitlab`, user: `hyper-expanse/open-source`}
const repository = parseRepositoryURL(`git@gitlab.com/hyper-expanse/open-source/parse-repository-url`);
repository.browse(); // https://gitlab.com/hyper-expanse/open-source/parse-repository-url
// {domain: `github.com`, project: `project`, type: `github`, user: `user`}
parseRepositoryURL(`https://github.com/user/project`);
// {domain: `git.example.com`, project: `project`, type: null, user: `user`}
parseRepositoryURL(`https://git.example.com/user/project`);
// {domain: `github.com`, project: `project`, type: `github`, user: `user`}
parseRepositoryURL(`git@github.com/user/project`);
// {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.
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.
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.
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]
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.
Please read our contributing guide to see how you may contribute to this project.
FAQs
Parse repository URLs to extract, SCM platform, domain, user, and project information.
The npm package @hutson/parse-repository-url receives a total of 1,598,678 weekly downloads. As such, @hutson/parse-repository-url popularity was classified as popular.
We found that @hutson/parse-repository-url demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.