All Projects → jonschlinkert → parse-github-url

jonschlinkert / parse-github-url

Licence: MIT license
Parse a Github URL into an object. Supports a wide variety of GitHub URL formats.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to parse-github-url

Djurl
Simple yet helpful library for writing Django urls by an easy, short and intuitive way.
Stars: ✭ 85 (-25.44%)
Mutual labels:  url, regex
es6-template-regex
Regular expression for matching es6 template delimiters in a string.
Stars: ✭ 15 (-86.84%)
Mutual labels:  parse, regex
parse-author
Parse a person, author, contributor or maintainer string into an object with name, email and url properties following NPM conventions. Useful for the `authors` property in package.json or for parsing an AUTHORS file into an array of person objects.
Stars: ✭ 23 (-79.82%)
Mutual labels:  parse, regex
golgi
A composable routing library for Haxe.
Stars: ✭ 37 (-67.54%)
Mutual labels:  url, parse
Url Regex
Regular expression for matching URLs
Stars: ✭ 286 (+150.88%)
Mutual labels:  url, regex
Parse Domain
Splits a hostname into subdomains, domain and (effective) top-level domains.
Stars: ✭ 261 (+128.95%)
Mutual labels:  url, parse
url-regex-safe
Regular expression matching for URL's. Maintained, safe, and browser-friendly version of url-regex. Resolves CVE-2020-7661 for Node.js servers.
Stars: ✭ 59 (-48.25%)
Mutual labels:  url, regex
Query String
Parse and stringify URL query strings
Stars: ✭ 5,781 (+4971.05%)
Mutual labels:  url, parse
Parseurl
parse a url with memoization
Stars: ✭ 162 (+42.11%)
Mutual labels:  url, parse
React Url Query
A library for managing state through query parameters in the URL in React
Stars: ✭ 195 (+71.05%)
Mutual labels:  url
Connector
Коннектор: удобный HTTP-клиент для 1С:Предприятие 8
Stars: ✭ 240 (+110.53%)
Mutual labels:  url
Urlbuilder
Java Builders: URL builder
Stars: ✭ 174 (+52.63%)
Mutual labels:  url
Vscode Remote Workspace
Multi protocol support for handling remote files like local ones in Visual Studio Code.
Stars: ✭ 197 (+72.81%)
Mutual labels:  url
Go Http Tunnel
Fast and secure tunnels over HTTP/2
Stars: ✭ 2,786 (+2343.86%)
Mutual labels:  url
Nanoid
A tiny, secure, URL-friendly, unique string ID generator for Rust
Stars: ✭ 188 (+64.91%)
Mutual labels:  url
use-route-as-state
Use React Router route and query string as component state
Stars: ✭ 37 (-67.54%)
Mutual labels:  url
New Github Issue Url
Generate a URL for opening a new GitHub issue with prefilled title, body, and other fields
Stars: ✭ 170 (+49.12%)
Mutual labels:  url
Furl
🌐 URL parsing and manipulation made easy.
Stars: ✭ 2,152 (+1787.72%)
Mutual labels:  url
ChromaTerm
Color your Terminal with RegEx!
Stars: ✭ 149 (+30.7%)
Mutual labels:  regex
ethereum-regex
Ξ Regular expression for matching Ethereum (ETH) addresses.
Stars: ✭ 19 (-83.33%)
Mutual labels:  regex

parse-github-url NPM version NPM monthly downloads NPM total downloads Linux Build Status

Parse a github URL into an object.

Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your ❤️ and support.

Install

Install with npm:

$ npm install --save parse-github-url

HEADS UP! Breaking changes in 0.3.0!!!

See the release history for details.

Why another GitHub URL parser library?

Seems like every lib I've found does too much, like both stringifying and parsing, or converts the URL from one format to another, only returns certain segments of the URL except for what I need, yields inconsistent results or has poor coverage.

Usage

var gh = require('parse-github-url');
gh('https://github.com/jonschlinkert/micromatch');

Results in:

{
  "owner": "jonschlinkert",
  "name": "micromatch",
  "repo": "jonschlinkert/micromatch",
  "branch": "master"
}

Example results

Generated results from test fixtures:

// assemble/verb#1.2.3
Url {
  protocol: null,
  slashes: null,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: null,
  hash: '#1.2.3',
  search: null,
  query: null,
  pathname: 'assemble/verb',
  path: 'assemble/verb',
  href: 'assemble/verb#1.2.3',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: '1.2.3',
  repository: 'assemble/verb' }

// assemble/verb#branch
Url {
  protocol: null,
  slashes: null,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: null,
  hash: '#branch',
  search: null,
  query: null,
  pathname: 'assemble/verb',
  path: 'assemble/verb',
  href: 'assemble/verb#branch',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'branch',
  repository: 'assemble/verb' }

// assemble/verb
Url {
  protocol: null,
  slashes: null,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: null,
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb',
  path: 'assemble/verb',
  href: 'assemble/verb',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// git+https://github.com/assemble/verb.git
Url {
  protocol: 'git+https:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb.git',
  path: 'assemble/verb.git',
  href: 'git+https://github.com/assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// git+ssh://github.com/assemble/verb.git
Url {
  protocol: 'git+ssh:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb.git',
  path: 'assemble/verb.git',
  href: 'git+ssh://github.com/assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// git://gh.pages.com/assemble/verb.git
Url {
  protocol: 'git:',
  slashes: true,
  auth: null,
  host: 'gh.pages.com',
  port: null,
  hostname: 'gh.pages.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb.git',
  path: 'assemble/verb.git',
  href: 'git://gh.pages.com/assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// git://github.assemble.com/assemble/verb.git
Url {
  protocol: 'git:',
  slashes: true,
  auth: null,
  host: 'github.assemble.com',
  port: null,
  hostname: 'github.assemble.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb.git',
  path: 'assemble/verb.git',
  href: 'git://github.assemble.com/assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// git://github.assemble.two.com/assemble/verb.git
Url {
  protocol: 'git:',
  slashes: true,
  auth: null,
  host: 'github.assemble.two.com',
  port: null,
  hostname: 'github.assemble.two.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb.git',
  path: 'assemble/verb.git',
  href: 'git://github.assemble.two.com/assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// git://github.com/assemble/verb
Url {
  protocol: 'git:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb',
  path: 'assemble/verb',
  href: 'git://github.com/assemble/verb',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// git://github.com/assemble/verb.git
Url {
  protocol: 'git:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb.git',
  path: 'assemble/verb.git',
  href: 'git://github.com/assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// git@gh.pages.com:assemble/verb.git
Url {
  protocol: null,
  slashes: null,
  auth: null,
  host: 'gh.pages.com',
  port: null,
  hostname: null,
  hash: null,
  search: null,
  query: null,
  pathname: '[email protected]:assemble/verb.git',
  path: '[email protected]:assemble/verb.git',
  href: '[email protected]:assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// git@github.com:assemble/verb.git#1.2.3
Url {
  protocol: null,
  slashes: null,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: null,
  hash: '#1.2.3',
  search: null,
  query: null,
  pathname: '[email protected]:assemble/verb.git',
  path: '[email protected]:assemble/verb.git',
  href: '[email protected]:assemble/verb.git#1.2.3',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: '1.2.3',
  repository: 'assemble/verb' }

// git@github.com:assemble/verb.git#v1.2.3
Url {
  protocol: null,
  slashes: null,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: null,
  hash: '#v1.2.3',
  search: null,
  query: null,
  pathname: '[email protected]:assemble/verb.git',
  path: '[email protected]:assemble/verb.git',
  href: '[email protected]:assemble/verb.git#v1.2.3',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'v1.2.3',
  repository: 'assemble/verb' }

// git@github.com:assemble/verb.git
Url {
  protocol: null,
  slashes: null,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: null,
  hash: null,
  search: null,
  query: null,
  pathname: '[email protected]:assemble/verb.git',
  path: '[email protected]:assemble/verb.git',
  href: '[email protected]:assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// github:assemble/verb
Url {
  protocol: 'github:',
  slashes: null,
  auth: null,
  host: 'assemble',
  port: null,
  hostname: 'assemble',
  hash: null,
  search: null,
  query: null,
  pathname: 'verb',
  path: 'verb',
  href: 'github:assemble/verb',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// http://github.com/assemble
Url {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble',
  path: 'assemble',
  href: 'http://github.com/assemble',
  filepath: null,
  owner: 'assemble',
  name: null,
  repo: null,
  branch: 'master',
  repository: null }

// http://github.com/assemble/verb
Url {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb',
  path: 'assemble/verb',
  href: 'http://github.com/assemble/verb',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// http://github.com/assemble/verb.git
Url {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb.git',
  path: 'assemble/verb.git',
  href: 'http://github.com/assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// http://github.com/assemble/verb/tree
Url {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb/tree',
  path: 'assemble/verb/tree',
  href: 'http://github.com/assemble/verb/tree',
  filepath: null,
  branch: 'tree',
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  repository: 'assemble/verb' }

// http://github.com/assemble/verb/tree/master
Url {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb/tree/master',
  path: 'assemble/verb/tree/master',
  href: 'http://github.com/assemble/verb/tree/master',
  filepath: null,
  branch: 'master',
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  repository: 'assemble/verb' }

// http://github.com/assemble/verb/tree/master/foo/bar
Url {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb/tree/master/foo/bar',
  path: 'assemble/verb/tree/master/foo/bar',
  href: 'http://github.com/assemble/verb/tree/master/foo/bar',
  filepath: null,
  branch: 'master',
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  repository: 'assemble/verb' }

// https://assemble.github.com/assemble/verb/somefile.tar.gz
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'assemble.github.com',
  port: null,
  hostname: 'assemble.github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb/somefile.tar.gz',
  path: 'assemble/verb/somefile.tar.gz',
  href: 'https://assemble.github.com/assemble/verb/somefile.tar.gz',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'somefile.tar.gz',
  repository: 'assemble/verb' }

// https://assemble.github.com/assemble/verb/somefile.zip
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'assemble.github.com',
  port: null,
  hostname: 'assemble.github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb/somefile.zip',
  path: 'assemble/verb/somefile.zip',
  href: 'https://assemble.github.com/assemble/verb/somefile.zip',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'somefile.zip',
  repository: 'assemble/verb' }

// https://assemble@github.com/assemble/verb.git
Url {
  protocol: 'https:',
  slashes: true,
  auth: 'assemble',
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb.git',
  path: 'assemble/verb.git',
  href: 'https://[email protected]/assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// https://gh.pages.com/assemble/verb.git
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'gh.pages.com',
  port: null,
  hostname: 'gh.pages.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb.git',
  path: 'assemble/verb.git',
  href: 'https://gh.pages.com/assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// https://github.com/assemble/verb
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb',
  path: 'assemble/verb',
  href: 'https://github.com/assemble/verb',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// https://github.com/assemble/verb.git
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb.git',
  path: 'assemble/verb.git',
  href: 'https://github.com/assemble/verb.git',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'master',
  repository: 'assemble/verb' }

// https://github.com/assemble/verb/blob/1.2.3/README.md
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb/blob/1.2.3/README.md',
  path: 'assemble/verb/blob/1.2.3/README.md',
  href: 'https://github.com/assemble/verb/blob/1.2.3/README.md',
  filepath: 'README.md',
  branch: '1.2.3',
  blob: '1.2.3/README.md',
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  repository: 'assemble/verb' }

// https://github.com/assemble/verb/blob/249b21a86400b38969cee3d5df6d2edf8813c137/README.md
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb/blob/249b21a86400b38969cee3d5df6d2edf8813c137/README.md',
  path: 'assemble/verb/blob/249b21a86400b38969cee3d5df6d2edf8813c137/README.md',
  href: 'https://github.com/assemble/verb/blob/249b21a86400b38969cee3d5df6d2edf8813c137/README.md',
  filepath: '249b21a86400b38969cee3d5df6d2edf8813c137/README.md',
  blob: '249b21a86400b38969cee3d5df6d2edf8813c137/README.md',
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'blob',
  repository: 'assemble/verb' }

// https://github.com/assemble/verb/blob/master/assemble/index.js
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb/blob/master/assemble/index.js',
  path: 'assemble/verb/blob/master/assemble/index.js',
  href: 'https://github.com/assemble/verb/blob/master/assemble/index.js',
  filepath: 'assemble/index.js',
  branch: 'master',
  blob: 'master/assemble/index.js',
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  repository: 'assemble/verb' }

// https://github.com/assemble/verb/tree/1.2.3
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb/tree/1.2.3',
  path: 'assemble/verb/tree/1.2.3',
  href: 'https://github.com/assemble/verb/tree/1.2.3',
  filepath: null,
  branch: '1.2.3',
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  repository: 'assemble/verb' }

// https://github.com/assemble/verb/tree/feature/1.2.3
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'assemble/verb/tree/feature/1.2.3',
  path: 'assemble/verb/tree/feature/1.2.3',
  href: 'https://github.com/assemble/verb/tree/feature/1.2.3',
  filepath: null,
  branch: 'feature',
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  repository: 'assemble/verb' }

// https://github.com/repos/assemble/verb/tarball
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'repos/assemble/verb/tarball',
  path: 'assemble/verb/tarball',
  href: 'https://github.com/repos/assemble/verb/tarball',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'tarball',
  repository: 'assemble/verb' }

// https://github.com/repos/assemble/verb/zipball
Url {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: 'repos/assemble/verb/zipball',
  path: 'assemble/verb/zipball',
  href: 'https://github.com/repos/assemble/verb/zipball',
  filepath: null,
  owner: 'assemble',
  name: 'verb',
  repo: 'assemble/verb',
  branch: 'zipball',
  repository: 'assemble/verb' }

History

v0.3.0

To be more consistent with node.js/package.json conventions, the following properties were renamed in v0.3.0:

  • repo is now name (project name)
  • repopath is now repository (project repository)
  • user is now owner (project owner or org)

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running Tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test
Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Related projects

You might also be interested in these projects:

Contributors

Commits Contributor
25 jonschlinkert
4 doowb
2 alferov
1 jmendiara
1 jeremyruppel
1 CookPete
1 iamwillbar
1 bmeiri

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on December 08, 2017.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].