Distopico Vegan 9e639edc8d | 6 years ago | |
---|---|---|
.. | ||
example | 6 years ago | |
test | 6 years ago | |
CONTRIBUTING.md | 6 years ago | |
LICENSE | 6 years ago | |
README.md | 6 years ago | |
package.json | 6 years ago |
Check if an input value is a ssh url or not.
$ npm i --save is-ssh
// Dependencies
const isSsh = require("is-ssh");
// Secure Shell Transport Protocol (SSH)
console.log(isSsh("ssh://user@host.xz:port/path/to/repo.git/"));
// true
console.log(isSsh("ssh://user@host.xz/path/to/repo.git/"));
// true
console.log(isSsh("ssh://host.xz:port/path/to/repo.git/"));
// true
console.log(isSsh("ssh://host.xz/path/to/repo.git/"));
// true
console.log(isSsh("ssh://user@host.xz/path/to/repo.git/"));
// true
console.log(isSsh("ssh://host.xz/path/to/repo.git/"));
// true
console.log(isSsh("ssh://user@host.xz/~user/path/to/repo.git/"));
// true
console.log(isSsh("ssh://host.xz/~user/path/to/repo.git/"));
// true
console.log(isSsh("ssh://user@host.xz/~/path/to/repo.git"));
// true
console.log(isSsh("ssh://host.xz/~/path/to/repo.git"));
// true
console.log(isSsh("user@host.xz:/path/to/repo.git/"));
// true
console.log(isSsh("user@host.xz:~user/path/to/repo.git/"));
// true
console.log(isSsh("user@host.xz:path/to/repo.git"));
// true
console.log(isSsh("host.xz:/path/to/repo.git/"));
// true
console.log(isSsh("host.xz:path/to/repo.git"));
// true
console.log(isSsh("host.xz:~user/path/to/repo.git/"));
// true
console.log(isSsh("rsync://host.xz/path/to/repo.git/"));
// true
// Git Transport Protocol
console.log(isSsh("git://host.xz/path/to/repo.git/"));
// false
console.log(isSsh("git://host.xz/~user/path/to/repo.git/"));
// false
// HTTP/S Transport Protocol
console.log(isSsh("http://host.xz/path/to/repo.git/"));
// false
console.log(isSsh("https://host.xz/path/to/repo.git/"));
// false
// Local (Filesystem) Transport Protocol
console.log(isSsh("/path/to/repo.git/"));
// false
console.log(isSsh("path/to/repo.git/"));
// false
console.log(isSsh("~/path/to/repo.git"));
// false
console.log(isSsh("file:///path/to/repo.git/"));
// false
console.log(isSsh("file://~/path/to/repo.git/"));
// false
isSsh(input)
Checks if an input value is a ssh url or not.
input
: The input url or an array of protocols.true
if the input is a ssh url, false
otherwise.Have an idea? Found a bug? See how to contribute.
If you are using this library in one of your projects, add it in this list. ✨