update
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
declare interface ParsedUrl {
|
||||
protocols: string[];
|
||||
protocol: string;
|
||||
port?: string;
|
||||
resource: string;
|
||||
user: string;
|
||||
pathname: string;
|
||||
hash: string;
|
||||
search: string;
|
||||
href: string;
|
||||
query: {
|
||||
[key: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
declare function parseUrl(url: string, normalize?: boolean | Object): ParsedUrl;
|
||||
|
||||
export default parseUrl
|
||||
+11
-15
@@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
"use strict"
|
||||
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
||||
|
||||
var parsePath = require("parse-path"),
|
||||
normalizeUrl = require("normalize-url");
|
||||
const parsePath = require("parse-path")
|
||||
, normalizeUrl = require("normalize-url")
|
||||
|
||||
/**
|
||||
* parseUrl
|
||||
@@ -34,22 +32,20 @@ var parsePath = require("parse-path"),
|
||||
* - `href` (String): The input url.
|
||||
* - `query` (Object): The url querystring, parsed as object.
|
||||
*/
|
||||
function parseUrl(url) {
|
||||
var normalize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
|
||||
function parseUrl(url, normalize = false) {
|
||||
if (typeof url !== "string" || !url.trim()) {
|
||||
throw new Error("Invalid url.");
|
||||
throw new Error("Invalid url.")
|
||||
}
|
||||
if (normalize) {
|
||||
if ((typeof normalize === "undefined" ? "undefined" : _typeof(normalize)) !== "object") {
|
||||
if (typeof normalize !== "object") {
|
||||
normalize = {
|
||||
stripFragment: false
|
||||
};
|
||||
stripHash: false
|
||||
}
|
||||
}
|
||||
url = normalizeUrl(url, normalize);
|
||||
url = normalizeUrl(url, normalize)
|
||||
}
|
||||
var parsed = parsePath(url);
|
||||
const parsed = parsePath(url)
|
||||
return parsed;
|
||||
}
|
||||
|
||||
module.exports = parseUrl;
|
||||
module.exports = parseUrl;
|
||||
|
||||
Reference in New Issue
Block a user