url-lib
Version:
A simple, lightweight string utility for Node and browsers that supports serializing and parsing URLs and query strings.
12 lines (11 loc) • 588 B
TypeScript
declare type UrlSegment = 'href' | 'fullDomain' | 'protocol' | 'host' | 'hostname' | '' | 'port' | 'pathname' | 'folderPath' | 'file' | 'fileName' | 'extension' | 'fileType' | 'search' | 'query' | 'hash' | 'anchor';
declare type ParsedUrl = {
[US in UrlSegment]: string;
};
/**
* Parses the specified URL string into an object containing properties for the various logical segments.
* @param {string | null} [url] URL to parse
* @returns {ParsedUrl} Parsed URL as url segments object
*/
declare const parseUrl: (url?: string | null | undefined) => ParsedUrl;
export default parseUrl;