is-ssh
Check if an input value is a ssh url or not.
Installation
$ npm i --save is-ssh
Example
const isSsh = require("is-ssh");
console.log(isSsh("ssh://user@host.xz:port/path/to/repo.git/"));
console.log(isSsh("ssh://user@host.xz/path/to/repo.git/"));
console.log(isSsh("ssh://host.xz:port/path/to/repo.git/"));
console.log(isSsh("ssh://host.xz/path/to/repo.git/"));
console.log(isSsh("ssh://user@host.xz/path/to/repo.git/"));
console.log(isSsh("ssh://host.xz/path/to/repo.git/"));
console.log(isSsh("ssh://user@host.xz/~user/path/to/repo.git/"));
console.log(isSsh("ssh://host.xz/~user/path/to/repo.git/"));
console.log(isSsh("ssh://user@host.xz/~/path/to/repo.git"));
console.log(isSsh("ssh://host.xz/~/path/to/repo.git"));
console.log(isSsh("user@host.xz:/path/to/repo.git/"));
console.log(isSsh("user@host.xz:~user/path/to/repo.git/"));
console.log(isSsh("user@host.xz:path/to/repo.git"));
console.log(isSsh("host.xz:/path/to/repo.git/"));
console.log(isSsh("host.xz:path/to/repo.git"));
console.log(isSsh("host.xz:~user/path/to/repo.git/"));
console.log(isSsh("rsync://host.xz/path/to/repo.git/"));
console.log(isSsh("git://host.xz/path/to/repo.git/"));
console.log(isSsh("git://host.xz/~user/path/to/repo.git/"));
console.log(isSsh("http://host.xz/path/to/repo.git/"));
console.log(isSsh("https://host.xz/path/to/repo.git/"));
console.log(isSsh("/path/to/repo.git/"));
console.log(isSsh("path/to/repo.git/"));
console.log(isSsh("~/path/to/repo.git"));
console.log(isSsh("file:///path/to/repo.git/"));
console.log(isSsh("file://~/path/to/repo.git/"));
Documentation
isSsh(input)
Checks if an input value is a ssh url or not.
Params
- String|Array
input
: The input url or an array of protocols.
Return
- Boolean
true
if the input is a ssh url, false
otherwise.
How to contribute
Have an idea? Found a bug? See how to contribute.
Where is this library used?
If you are using this library in one of your projects, add it in this list. :sparkles:
License
MIT © Ionică Bizău