JSPM

  • Created
  • Published
  • Downloads 56311
  • Score
    100M100P100Q178650F
  • License MIT

URL Connection String Parser.

Package Exports

  • connection-string

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (connection-string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

connection-string

URL Connection String Parser - for all browsers and Node.js versions.

Build Status Coverage Status

Accepts a URL connection string (with every element being optional):

protocol://user:password@hostname:12345/segment1/segment2?param1=value1&param2=value2

and converts it into an object:

{
    protocol: 'protocol',
    user: 'user',
    password: 'password',
    host: 'hostname:12345',
    hostname: 'hostname',
    port: 12345,
    segments: ['segment1', 'segment2'],
    params: {
        param1: 'value1',
        param2: 'value2'
    }
}

Only those properties are set that are present in the connection string.

Installing

$ npm install connection-string

Usage

  • Node.js
var parse = require('connection-string');
var obj = parse('my-server:12345');
  • Browsers
<script src="./connection-string/src"></script>

<script>
    var obj = parseConnectionString('my-server:12345');
</script>
  • TypeScript
import * as parse from './connection-string/src'
import {ConnectionOptions} from './connection-string/src'

var a: ConnectionOptions = parse('protocol://');

For details and examples see the WiKi Pages.