Socket
Book a DemoInstallSign in
Socket

get-github-url

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-github-url

Get a complete (or a canonical) GitHub repository URL (https or ssh) from an incomplete URL or a user/repo path

1.0.4
latest
Source
npmnpm
Version published
Weekly downloads
16
-42.86%
Maintainers
1
Weekly downloads
 
Created
Source

get-github-url Build Status

Get a complete (or a canonical) GitHub repository URL (https or ssh) from an incomplete URL or a user/repo path

Installation

$ npm install get-github-url --save

Usage

var getGithubUrl = require('get-github-url');

// HTTPS
getGithubUrl('facebook/react');
// => 'https://github.com/facebook/react'
getGithubUrl('github.com/facebook/react');
// => 'https://github.com/facebook/react'
getGithubUrl('git@github.com:facebook/react.git');
// => 'https://github.com/facebook/react'
getGithubUrl('//github.com/facebook/react.git');
// => 'https://github.com/facebook/react'

// SSH
getGithubUrl('facebook/react', { protocol: 'ssh' });
 // => 'git@github.com:facebook/react.git'
getGithubUrl('github.com/facebook/react', { protocol: 'ssh' });
 // => 'git@github.com:facebook/react.git'
getGithubUrl('git@github.com:facebook/react.git', { protocol: 'ssh' });
// => 'git@github.com:facebook/react.git'
getGithubUrl('//github.com/facebook/react.git', { protocol: 'ssh' });
// => 'git@github.com:facebook/react.git'

// Prepare URL for cloning:
getGithubUrl('facebook/react', { cloning: true });
// => 'https://github.com/facebook/react.git'
getGithubUrl('facebook/react', { cloning: true, ssh: true });
// => 'git@github.com:facebook/react.git'

API

getGithubUrl(input, options)

Get a complete (or a canonical) GitHub repository URL (https or ssh) from an incomplete URL or a user/repo path

Params

  • String input: a URL or a user/repo path
  • Object options: An object containing the following fields:
    • protocol (String): A format of returned URL. Possible values: ssh (https is used by default)
    • cloning (Boolean): Make a URL acceptable for git clone command

Return

  • String | Null: A valid GitHub URL or null

License

MIT © Philipp Alferov

Keywords

github

FAQs

Package last updated on 24 Oct 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.