Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "ssh-url", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "ssh-url", | ||
@@ -25,5 +25,5 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mocha": "~1.13.0", | ||
"chai": "~1.8.0" | ||
"mocha": "^1.13.0", | ||
"chai": "^1.8.0" | ||
} | ||
} |
# ssh-url [![NPM version](https://badge.fury.io/js/ssh-url.svg)](http://badge.fury.io/js/ssh-url) [![Build Status](https://travis-ci.org/kaelzhang/node-ssh-url.svg?branch=master)](https://travis-ci.org/kaelzhang/node-ssh-url) [![Dependency Status](https://gemnasium.com/kaelzhang/node-ssh-url.svg)](https://gemnasium.com/kaelzhang/node-ssh-url) | ||
Utilities to resolute and parse ssh url including scp-like syntax SSH protocol. | ||
## Installation | ||
```bash | ||
$ npm install ssh-url --save | ||
``` | ||
## Usage | ||
```js | ||
var url = require('ssh-url'); | ||
var parsed = url.parse('git@github.com:kaelzhang/node-ssh-url.git'); | ||
// -> { | ||
// protocol: null, | ||
// user: 'git', | ||
// hostname: 'github.com', | ||
// pathname: 'kaelzhang/node-ssh-url.git' | ||
// } | ||
url.format(parsed); | ||
// -> git@github.com:kaelzhang/node-ssh-url.git | ||
``` | ||
### url.parse(urlStr) | ||
Takes a SSH URL string, and returns an object. | ||
#### urlObj | ||
For now, `urlObj` only contains four properties. | ||
- protocol `null|String` if null, indicates that `urlStr` uses scp-like syntax. | ||
- user `String` | ||
- hostname `String` for now, there's no port. | ||
- pathname `String` starts with `'/'` | ||
### url.format(urlObj) | ||
Takes a parsed SSH URL object, and returns a formatted URL string. |
'use strict'; | ||
var expect = require('chai').expect; | ||
var ssh_url = require('../'); | ||
var url = require('../'); | ||
var cases = [ | ||
{ | ||
d: 'scp-like syntax', | ||
u: 'git@github.com:kaelzhang/node-ssh-url.git', | ||
e: { | ||
protocol: null, | ||
user: 'git', | ||
hostname: 'github.com', | ||
pathname: '/kaelzhang/node-ssh-url.git' | ||
} | ||
}, | ||
{ | ||
d: 'ssh protocol', | ||
u: 'ssh://git@github.com/kaelzhang/node-ssh-url.git', | ||
e: { | ||
protocol: 'ssh:', | ||
user: 'git', | ||
hostname: 'github.com', | ||
pathname: '/kaelzhang/node-ssh-url.git' | ||
} | ||
} | ||
]; | ||
describe("url.parse(str), url.format(obj)", function(){ | ||
cases.forEach(function (c) { | ||
it(c.d, function(){ | ||
var parsed = url.parse(c.u); | ||
expect(parsed).to.deep.equal(c.e); | ||
var formated = url.format(parsed); | ||
expect(formated).to.equal(c.u); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
5220
76
43
0