Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@-0/utils

Package Overview
Dependencies
Maintainers
1
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@-0/utils - npm Package Compare versions

Comparing version 0.2.65 to 0.2.66

9

lib/URL.d.ts

@@ -10,2 +10,9 @@ import { URL_FULL, URL_SUBD, URL_DOMN, URL_QERY, URL_HASH, URL_PATH } from "@-0/keys";

};
export declare const unparse: (parsed: any, isAbsolute?: boolean) => string;
export declare const unparse: (parsed?: {
URL: string;
URL_subdomain: any[];
URL_domain: any[];
URL_path: any[];
URL_query: any;
URL_hash: string;
}, isAbsolute?: boolean) => string;

35

lib/URL.js

@@ -12,3 +12,3 @@ import qs from "querystring";

const path_str = parts[0];
const full_path = path_str.split("/").filter(x => x !== "");
const full_path = path_str.split("/").filter((x) => x !== "");
if (/http/i.test(URL_full)) {

@@ -22,5 +22,5 @@ URL_domain = full_path[1].split(".").slice(-2);

}
const query_str = parts.filter(part => part.slice(0, 1) === "?")[0] || "";
const hash_str = parts.filter(part => part.slice(0, 1) === "#")[0] || "";
const URL_query = qs.parse(query_str.slice(1));
const query_str = parts.filter((part) => part.slice(0, 1) === "?")[0] || "";
const hash_str = parts.filter((part) => part.slice(0, 1) === "#")[0] || "";
const URL_query = JSON.parse(JSON.stringify(qs.decode(query_str.slice(1))));
const URL_hash = hash_str.slice(1);

@@ -33,21 +33,20 @@ return {

[URL_QERY]: URL_query,
[URL_HASH]: URL_hash
[URL_HASH]: URL_hash,
};
};
export const unparse = (parsed, isAbsolute = false) => {
const { [URL_SUBD]: URL_subdomain, [URL_DOMN]: URL_domain, [URL_PATH]: URL_path, [URL_QERY]: URL_query, [URL_HASH]: URL_hash } = parse(parsed[URL_FULL] || window.location.href);
const { _URL_subdomain = URL_subdomain, _URL_domain = URL_domain, _URL_path = URL_path, _URL_query = URL_query, _URL_hash = URL_hash } = parsed;
const [protocol, rest] = URL_FULL.split("//");
export const unparse = (parsed = parse(window.location.href), isAbsolute = false) => {
const { [URL_FULL]: URL, [URL_SUBD]: URL_subdomain, [URL_DOMN]: URL_domain, [URL_PATH]: URL_path, [URL_QERY]: URL_query, [URL_HASH]: URL_hash, } = parsed;
const [protocol, rest] = parsed[URL_FULL].split("//");
const [root] = rest.split("/");
const [part_one, ...other_parts] = root.split(".");
const domain = _URL_subdomain && _URL_domain
? [..._URL_subdomain, ..._URL_domain]
: _URL_subdomain && other_parts.length > 1
? [..._URL_subdomain, ...other_parts]
: _URL_subdomain && other_parts.length === 1
? [..._URL_subdomain, part_one, ...other_parts]
: [..._URL_subdomain, part_one];
const query_string = qs.encode(_URL_query);
const rootRelative = `${_URL_path.length > 0 ? "/" + _URL_path.join("/") : ""}${_URL_hash ? "#" + _URL_hash : null}?${query_string}`;
const domain = URL_subdomain && URL_domain
? [...URL_subdomain, ...URL_domain]
: URL_subdomain && other_parts.length > 1
? [...URL_subdomain, ...other_parts]
: URL_subdomain && other_parts.length === 1
? [...URL_subdomain, part_one, ...other_parts]
: [...URL_subdomain, part_one];
const query_string = qs.encode(URL_query);
const rootRelative = `${URL_path.length > 0 ? "/" + URL_path.join("/") : ""}${query_string ? "?" + query_string : ""}${URL_hash ? "#" + URL_hash : ""}`;
return !isAbsolute ? rootRelative : `${protocol}//${domain.join(".")}${rootRelative}`;
};

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.2.65",
"version": "0.2.66",
"description": "utilities for the `-0` org/framework built on @thi.ng/umbrella ecosystem",

@@ -34,15 +34,20 @@ "main": "./lib/index.js",

"peerDependencies": {
"@-0/keys": "^0.2.71",
"@thi.ng/checks": "^2.6.2",
"@thi.ng/rstream": "^4.0.5"
"@-0/keys": "^0.2.72",
"@thi.ng/checks": "^2.6.3",
"@thi.ng/rstream": "^4.0.6"
},
"devDependencies": {
"@-0/keys": "^0.2.71",
"@thi.ng/checks": "^2.6.2",
"@thi.ng/rstream": "^4.0.5",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"@babel/plugin-transform-modules-commonjs": "^7.9.0",
"@-0/keys": "^0.2.72",
"@thi.ng/checks": "^2.6.3",
"@thi.ng/rstream": "^4.0.6",
"@types/jest": "^25.2.1",
"@types/node": "^13.13.4",
"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
"babel-jest": "^25.4.0",
"eslint": "^6.8.0",
"jest": "^25.4.0",
"prettier": "^2.0.5"
"prettier": "^2.0.5",
"ts-jest": "^25.4.0"
},

@@ -49,0 +54,0 @@ "publishConfig": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc