URL Parser & Builder
yarn add @sudoo/url
# Or
npm install @sudoo/url --save
import { buildUrl, URLLeanStructure } from "@sudoo/url";
const structure: URLLeanStructure = {
protocol: URL_PROTOCOL.HTTPS,
host: [hostName, 'com'],
path: [],
hash: [],
params: {},
};
const url: string = buildUrl(structure);
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',
},
}) */