![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
parse-git-url
Advanced tools
The parse-git-url npm package is a utility for parsing Git URLs into their component parts. It supports various Git URL formats and provides a simple interface to extract information such as the protocol, host, owner, name, and more.
Parse Git URL
This feature allows you to parse a Git URL and extract its components. The code sample demonstrates how to parse a Git URL and log the parsed object, which includes properties like protocol, host, owner, and name.
const parseGitUrl = require('parse-git-url');
const parsed = parseGitUrl('https://github.com/user/repo.git');
console.log(parsed);
Support for Different Git URL Formats
This feature shows the package's ability to handle different Git URL formats, such as SSH and HTTPS. The code sample demonstrates parsing both an SSH URL and an HTTPS URL, logging the parsed objects for each.
const parseGitUrl = require('parse-git-url');
const sshUrl = parseGitUrl('git@github.com:user/repo.git');
const httpsUrl = parseGitUrl('https://github.com/user/repo.git');
console.log(sshUrl);
console.log(httpsUrl);
Extract Specific Components
This feature allows you to extract specific components from a parsed Git URL. The code sample demonstrates how to extract and log the owner and repository name from a parsed Git URL.
const parseGitUrl = require('parse-git-url');
const parsed = parseGitUrl('https://github.com/user/repo.git');
const owner = parsed.owner;
const name = parsed.name;
console.log(`Owner: ${owner}, Repo Name: ${name}`);
The git-url-parse package provides similar functionality to parse-git-url, allowing you to parse Git URLs and extract their components. It also supports various Git URL formats and offers additional methods for manipulating and formatting Git URLs.
The parse-url package is a more general-purpose URL parser that can handle Git URLs among other types of URLs. It provides a comprehensive set of features for parsing, manipulating, and formatting URLs, making it a versatile alternative to parse-git-url.
The url-parse package is another general-purpose URL parser that can handle Git URLs. It offers a robust set of features for parsing and manipulating URLs, and it is widely used in the JavaScript ecosystem for various URL parsing needs.
A lib for parsing the URL of GitHub, GitHub Enterprise Server (ghes), GitLab, and Bitbucket repositories.
import parseGitUrl from 'parse-git-url'
parseGitUrl('https://github.com/vercel/swr'))
// => {
// type: 'github',
// owner: 'vercel',
// name: 'swr',
// branch: '',
// sha: '',
// subdir: ''
// }
parseGitUrl('https://github.example.com/vercel/swr', 'github.example.com'))
// => {
// type: 'ghes',
// owner: 'vercel',
// name: 'swr',
// branch: '',
// sha: '',
// subdir: ''
// }
parseGitUrl('https://google.com')
// => null
It supports parsing various URL schemas including SSH, branch, sha, commit, subdirectories, subgroups (GitLab), etc.
FAQs
A lib for parsing the URL of Git Repositories.
We found that parse-git-url demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.