Sudoo-URL

Continuous Integration codecov npm version downloads

URL Parser & Builder

Install

yarn add @sudoo/url
# Or
npm install @sudoo/url --save

Build URL

import { buildUrl, URLLeanStructure } from "@sudoo/url";

const structure: URLLeanStructure = {

    protocol: URL_PROTOCOL.HTTPS,
    host: [hostName, 'com'],
    path: [],
    hash: [],
    params: {},
};
const url: string = buildUrl(structure);

Parse URL

import { parseUrl, URLLeanStructure } from "@sudoo/url";

const url: string = 'http://example.com/first?a=b';

const result: URLLeanStructure = parseUrl(url);

result; 
/** {
    protocol: URL_PROTOCOL.HTTP,
    host: ['example', 'com'],
    path: ['first'],
    hash: [],
    params: {
        a: 'b',
    },
}) */