UNPKG

shurley

Version:

Validate or fix URLs from user input. People make mistakes!

30 lines 1.09 kB
/** * This function parses a URL from user input (with potential typos in protocols, bad copy+paste, etc.) and returns a proper URL. * * ```ts * parse("example.com") // "https://example.com" * parse("http://example.com") // "http://example.com" * parse("https://example.com") // "https://example.com" * parse("ftp://example.com") // "https://example.com" * parse("example.com/path") // "https://example.com/path" * parse("example.com/path/to/resource?query=string#fragment") // "https://example.com/path/to/resource?query=string#fragment" * ``` * * @param url - The URL to parse. * @returns The parsed URL. */ export declare const parse: (url: string) => string; /** * This simply exports the `parse` function as the default export. * * ```ts * import shurley from 'jsr:@brn/shurley@1.0.9'; // or import shurley from 'https://deno.land/x/shurley@1.0.9/mod.ts'; * * const parsedUrl = shurley.parse('example.com'); // "https://example.com" * ``` */ declare const _default: { parse: (url: string) => string; }; export default _default; //# sourceMappingURL=mod.d.ts.map