This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+18
View File
@@ -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
View File
@@ -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;