mini-url
Advanced tools
Comparing version 2.1.7 to 2.1.8
@@ -9,9 +9,19 @@ import * as T from "./_types"; | ||
/** | ||
* @description | ||
* Creates a browser style URL object. | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/URL} | ||
* See: https://developer.mozilla.org/en-US/docs/Web/API/URL | ||
* | ||
* @example | ||
* parse("http//google.ca") // { protocol: "http", hostname: "google", ... } | ||
* | ||
* @param url The url string to parse. | ||
* @param base The base part of the url to resolve from. | ||
*/ | ||
export declare function parse(path: string, base?: string): T.URL; | ||
export declare function parse(url: string, base?: string): T.URL; | ||
/** | ||
* @description | ||
* Converts a URL like object into an href. | ||
* | ||
* @param parsed A parsed url object containing. | ||
*/ | ||
export declare function stringify(parsed: T.URL): string; |
@@ -12,7 +12,14 @@ "use strict"; | ||
/** | ||
* @description | ||
* Creates a browser style URL object. | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/URL} | ||
* See: https://developer.mozilla.org/en-US/docs/Web/API/URL | ||
* | ||
* @example | ||
* parse("http//google.ca") // { protocol: "http", hostname: "google", ... } | ||
* | ||
* @param url The url string to parse. | ||
* @param base The base part of the url to resolve from. | ||
*/ | ||
function parse(path, base) { | ||
var key = path + separator + base; | ||
function parse(url, base) { | ||
var key = url + separator + base; | ||
// Try to return cached url. | ||
@@ -24,3 +31,3 @@ var cached = cache[key]; | ||
// Parse url and cache result. | ||
var parsed = base ? new url_1.URL(path, base) : new url_1.URL(path); | ||
var parsed = base ? new url_1.URL(url, base) : new url_1.URL(url); | ||
var result = { toString: toString }; | ||
@@ -41,3 +48,6 @@ // Make each part default to empty string for consistency. | ||
/** | ||
* @description | ||
* Converts a URL like object into an href. | ||
* | ||
* @param parsed A parsed url object containing. | ||
*/ | ||
@@ -58,2 +68,3 @@ function stringify(parsed) { | ||
/** | ||
* @description | ||
* To string method for cloned urls. | ||
@@ -60,0 +71,0 @@ */ |
{ | ||
"name": "mini-url", | ||
"description": "Lightweight isomorphic url parser.", | ||
"version": "2.1.7", | ||
"version": "2.1.8", | ||
"author": "Dylan Piercey <pierceydylan@gmail.com>", | ||
@@ -6,0 +6,0 @@ "browser": { |
Sorry, the diff of this file is not supported yet
17060
266