Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

uri-sharp

brunolm7MIT1.0.1TypeScript support: included

Parse an URI and return an object. Similar to .NET Uri class.

readme

uri-sharp

Install

npm i -S uri-sharp

TypeScript definitions included.

Example

import parseUri from 'uri-sharp';

const uriText = 'http://www.codingwise.com/blog/?search=csharp#hash=net&ok=1';
const uri = parseUri(uriText);

assert.deepEqual(uri, {
  absolutePath: '/blog/',
  absoluteUri: uriText,
  authority: 'www.codingwise.com',
  hash: {
    hash: 'net',
    ok: '1',
  },
  hashString: '#hash=net&ok=1',
  host: 'www.codingwise.com',
  hostNameType: 'dns',
  isDefaultPort: true,
  originalString: uriText,
  pathAndQuery: '/blog/?search=csharp',
  port: 80,
  query: {
    search: 'csharp',
  },
  queryString: '?search=csharp',
  scheme: 'http',
});