Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ssh-url

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssh-url - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

6

package.json
{
"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);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc