Skip to content

bevacqua/omnibox

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

omnibox

Fast url parsing with a tiny footprint and extensive browser support

This module is mostly a re-implementation of fast-url-parser designed to make the footprint smaller and the browser support broader.

install

npm install omnibox --save
bower install omnibox --save

assumptions

Use omnibox only if you don't need any of the features shown below.

  • Support for malformed input
  • Support for a protocol other than http, https
  • Basic authentication support http://user:pwd@domain.com
  • IDNA support (special characters in host)
  • options
  • Anything that's not provided by the .parse method

If you need any of those features, use the more comprehensive fast-url-parser instead. Note that browser support is smaller because they rely on Uint8Array, and their footprint is also larger.

omnibox.parse(url)

Parses a URL string and returns its different components. The query string is parsed by default. There's no option that prevents this behavior.

Example

Result for omnibox.parse('https://stompflow.com/foo?bar=23&baz=abc#hash-parts').

{ protocol: 'https',
  hostname: 'stompflow.com',
  host: 'stompflow.com',
  port: undefined,
  pathname: '/foo',
  path: '/foo?bar=23&baz=abc',
  search: '?bar=23&baz=abc',
  hash: '#hash-parts',
  query: { bar: '23', baz: 'abc' } }

omnibox/querystring

You could also just parse the query string part. See the example below.

var parse = require('omnibox/querystring').parse
parse('bar=23&baz=abc')
// <- { bar: '23', baz: 'abc' }

License

MIT

About

Fast url parsing with a tiny footprint and extensive browser support

Resources

License

Stars

Watchers

Forks

Packages

No packages published