1.4.1 • Published 5 years ago

libj-url v1.4.1

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

libj-url

Part of libj tools

Contains logic for parsing and manipulating urls

Usage (npm)

npm install libj-url

Example

import { urlParser } from 'libj-url'
var o = urlParser.parse('/api/authentication/login?user_name=admin&password=pass 1#anchor')

/*
returns the following object
{
    protocol: 'http:' or 'https:'   // based on the current url
    host: 'localhost:1234'          // based on the current url
    hostname: 'localhost'           // based on the current url
    port: '1234'                    // based on the current url
    pathname: '/api/authentication/login'
    search: '?user_name=admin&password=pass 1'
    query: {
        'user_name': 'admin',
        'password': 'pass 1'
    },
    hash: '#anchor'
}
*/

var urlAbsolute = o.toAbsolute()

/*
returns 'http://localhost:1234/api/authentication/login?user_name=admin&password=pass%201#anchor'
*/

var urlRelative = o.toRelative()

/*
returns '/api/authentication/login?user_name=admin&password=pass%201#anchor'
*/

var query = urlParser.parseQueryString('user_name=admin&password=pass 1');
/*
returns 
{
    "user_name":"admin",
    "password":"pass 1"
}
*/

var search = urlParser.stringifyQueryString(query)

/*
returns 'user_name=admin&password=pass%201'
*/

Coverage tests

  • Run this
npm test

Test

  • Run this in a separate command line to start node server
node server.js
  • Run one of the following to re-create bundles
npm run dev
npm run dev:watch

Build

npm run build
npm run build:watch

Make sure to test everything in all browsers (specially IE 10/11)

1.4.1

5 years ago

1.4.0

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago