Check if a URL is a valid and existent GitHub HTTP(s) URL
$ npm install --save github-url-exists
var githubUrlExists = require('github-url-exists');
githubUrlExists('https://github.com/alferov/awesome-gulp', function(err, valid) {
if (err) {
// Handle errors
}
console.log(valid); // => true
});
githubUrlExists('https://github.com/alferov/awesome-gulp.git', function(err, valid) {
if (err) {
// Handle errors
}
console.log(valid); // => true
});
githubUrlExists('https://github.com/notthepage/notthepage', function(err, valid) {
if (err) {
// Handle errors
}
console.log(valid); // => false
});
githubUrlExists('google.com/', function(err, valid) {
if (err) {
// Handle errors
}
console.log(valid); // => false
});
//Warning: The package doesn't support ssh protocol
githubUrlExists('git@github.com:alferov/awesome-gulp.git', function(err, valid) {
if (err) {
// Handle errors
}
console.log(valid); // => false
});
Check if a URL is a valid and existent GitHub HTTP(s) URL
- String
url
: A string to be validated - Function
cb
: The callback function
MIT © Philipp Alferov