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, with fully optional syntax.
Takes a URL connection string (with every element being optional):
protocol://user:password@hostname:12345/seg1/seg2?p1=val1&p2=val2and converts it into an object that contains only what's specified:
{
protocol: 'protocol',
user: 'user',
password: 'password',
host: 'hostname:12345',
hostname: 'hostname',
port: 12345,
segments: ['seg1', 'seg2'],
params: {
p1: 'val1',
p2: 'val2'
}
}Short-syntax examples:
localhost=>{host: 'localhost', hostname: 'localhost'}localhost:12345=>{host: 'localhost:12345', hostname: 'localhost', port: 12345}abc:///seg1?p1=val=>{protocol: 'abc', segments: ['seg1'], params: {p1: 'val'}}:12345=>{host: ':12345', port: 12345}username@=>{user: 'username'}:pass123@=>{password: 'pass123'}/seg1/seg2=>{segments: ['seg1', 'seg2']}?param1=1¶m2=2=>{params: {param1: '1', param2: '2'}}
For a complete list of short-syntax examples see the Optional Format.
All browsers and Node.js versions are supported.
Installing
$ npm install connection-stringUsage
- 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'
import {ConnectionOptions} from 'connection-string'
var a: ConnectionOptions = parse('my-server:12345');For details and examples see the WiKi Pages.