is-github-url
Check if a passed string is a valid GitHub URL
Unlike is-git-url, is-github-url is a domain-specific validator. It returns true
if passed URL is a part of github.com
domain only.
Installation
$ npm install is-github-url --save
Usage
var isGithubUrl = require('is-github-url');
isGithubUrl('https://github.com/facebook');
isGithubUrl('https://github.com/facebook/react');
isGithubUrl('https://github.com/facebook/react/releases/tag/v0.14.0');
isGithubUrl('git@github.com:facebook/react.git');
isGithubUrl('git://github.com/facebook/react.git#gh-pages');
isGithubUrl('https://google.com');
isGithubUrl('unknown://github.com');
isGithubUrl('http://facebook.github.io/');
isGithubUrl('https://github.com/facebook/react', { repository: true });
isGithubUrl('https://github.com/facebook', { repository: true });
isGithubUrl('https://github.com/facebook/react/releases/tag/v0.14.0', {
repository: true
});
isGithubUrl('https://github.com/facebook/react.git', { strict: true });
isGithubUrl('https://github.com/facebook/react', { strict: true });
API
isGithubUrl(url, [options])
Check if a passed string is a valid GitHub URL
Params
- String
url
: A string to be validated - Object
options
: An object containing the following fields:
strict
(Boolean): Match only URLs ending with .gitrepository
(Boolean): Match only valid GitHub repo URLs
License
MIT © Philipp Alferov