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

kaven-basic

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kaven-basic - npm Package Compare versions

Comparing version 4.3.1 to 4.3.2

105

esm2015/libs/KavenUrl.js

@@ -7,7 +7,7 @@ /********************************************************************

* @create: 2022-04-14 15:56:19.960
* @modify: 2022-07-02 10:04:15.377
* @version: 4.2.0
* @times: 17
* @lines: 122
* @copyright: Copyright © 2022 Kaven. All Rights Reserved.
* @modify: 2023-11-30 17:24:59.458
* @version: 4.3.2
* @times: 21
* @lines: 138
* @copyright: Copyright © 2022-2023 Kaven. All Rights Reserved.
* @description: [description]

@@ -17,47 +17,11 @@ * @license: [license]

/**
*
* Represents a utility class for handling and parsing URLs.
* @since 4.0.0
* @version 2022-06-26
* @version 2023-11-30
* @see https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL
*/
export class KavenUrl {
constructor(url) {
constructor(url = "") {
this.OriginalUrl = url;
if (url.includes("://")) {
const u = new URL(url);
this.Scheme = u.protocol.TrimEnd(":");
this.DomainName = u.hostname;
if (u.port.length > 0) {
this.Port = Number(u.port);
}
else {
const protocolPort = [
["ftp", 21],
["http", 80],
["https", 443],
["ws", 80],
["wss", 443],
];
for (const item of protocolPort) {
const [protocol, port] = item;
if (this.Scheme.toLowerCase() === protocol) {
this.Port = port;
break;
}
}
}
this.Path = u.pathname;
this.Parameters = u.search;
this.Anchor = u.hash;
}
else {
const u = new URL("http://" + url);
this.DomainName = u.hostname;
if (u.port.length > 0) {
this.Port = Number(u.port);
}
this.Path = u.pathname;
this.Parameters = u.search;
this.Anchor = u.hash;
}
this.TryParse(url);
}

@@ -96,3 +60,54 @@ get PathAndParameters() {

}
TryParse(url) {
try {
// Check if the URL contains a protocol (e.g., "http://")
if (url.includes("://")) {
const u = new URL(url);
// Extract scheme, domain name, and port from the URL
this.Scheme = u.protocol.TrimEnd(":");
this.DomainName = u.hostname;
// Determine port based on the scheme if not specified
if (u.port.length > 0) {
this.Port = Number(u.port);
}
else {
const protocolPort = [
["ftp", 21],
["http", 80],
["https", 443],
["ws", 80],
["wss", 443],
];
for (const [protocol, port] of protocolPort) {
if (this.Scheme.toLowerCase() === protocol) {
this.Port = port;
break;
}
}
}
// Extract path, parameters, and anchor from the URL
this.Path = u.pathname;
this.Parameters = u.search;
this.Anchor = u.hash;
}
else {
// If no protocol is provided, assume "http://"
const u = new URL("http://" + url);
this.DomainName = u.hostname;
// Extract port if specified
if (u.port.length > 0) {
this.Port = Number(u.port);
}
// Extract path, parameters, and anchor from the URL
this.Path = u.pathname;
this.Parameters = u.search;
this.Anchor = u.hash;
}
}
catch (_a) {
return false;
}
return true;
}
}
//# sourceMappingURL=KavenUrl.js.map

@@ -7,7 +7,7 @@ /********************************************************************

* @create: 2022-04-14 15:56:19.960
* @modify: 2022-07-02 10:04:15.377
* @version: 4.2.0
* @times: 17
* @lines: 122
* @copyright: Copyright © 2022 Kaven. All Rights Reserved.
* @modify: 2023-11-30 17:24:59.458
* @version: 4.3.2
* @times: 21
* @lines: 138
* @copyright: Copyright © 2022-2023 Kaven. All Rights Reserved.
* @description: [description]

@@ -17,5 +17,5 @@ * @license: [license]

/**
*
* Represents a utility class for handling and parsing URLs.
* @since 4.0.0
* @version 2022-06-26
* @version 2023-11-30
* @see https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL

@@ -25,41 +25,5 @@ */

function KavenUrl(url) {
if (url === void 0) { url = ""; }
this.OriginalUrl = url;
if (url.includes("://")) {
var u = new URL(url);
this.Scheme = u.protocol.TrimEnd(":");
this.DomainName = u.hostname;
if (u.port.length > 0) {
this.Port = Number(u.port);
}
else {
var protocolPort = [
["ftp", 21],
["http", 80],
["https", 443],
["ws", 80],
["wss", 443],
];
for (var _i = 0, protocolPort_1 = protocolPort; _i < protocolPort_1.length; _i++) {
var item = protocolPort_1[_i];
var protocol = item[0], port = item[1];
if (this.Scheme.toLowerCase() === protocol) {
this.Port = port;
break;
}
}
}
this.Path = u.pathname;
this.Parameters = u.search;
this.Anchor = u.hash;
}
else {
var u = new URL("http://" + url);
this.DomainName = u.hostname;
if (u.port.length > 0) {
this.Port = Number(u.port);
}
this.Path = u.pathname;
this.Parameters = u.search;
this.Anchor = u.hash;
}
this.TryParse(url);
}

@@ -102,2 +66,54 @@ Object.defineProperty(KavenUrl.prototype, "PathAndParameters", {

};
KavenUrl.prototype.TryParse = function (url) {
try {
// Check if the URL contains a protocol (e.g., "http://")
if (url.includes("://")) {
var u = new URL(url);
// Extract scheme, domain name, and port from the URL
this.Scheme = u.protocol.TrimEnd(":");
this.DomainName = u.hostname;
// Determine port based on the scheme if not specified
if (u.port.length > 0) {
this.Port = Number(u.port);
}
else {
var protocolPort = [
["ftp", 21],
["http", 80],
["https", 443],
["ws", 80],
["wss", 443],
];
for (var _i = 0, protocolPort_1 = protocolPort; _i < protocolPort_1.length; _i++) {
var _a = protocolPort_1[_i], protocol = _a[0], port = _a[1];
if (this.Scheme.toLowerCase() === protocol) {
this.Port = port;
break;
}
}
}
// Extract path, parameters, and anchor from the URL
this.Path = u.pathname;
this.Parameters = u.search;
this.Anchor = u.hash;
}
else {
// If no protocol is provided, assume "http://"
var u = new URL("http://" + url);
this.DomainName = u.hostname;
// Extract port if specified
if (u.port.length > 0) {
this.Port = Number(u.port);
}
// Extract path, parameters, and anchor from the URL
this.Path = u.pathname;
this.Parameters = u.search;
this.Anchor = u.hash;
}
}
catch (_b) {
return false;
}
return true;
};
return KavenUrl;

@@ -104,0 +120,0 @@ }());

{
"name": "kaven-basic",
"version": "4.3.1",
"version": "4.3.2",
"description": "Basic library for javascript/typescript.",

@@ -5,0 +5,0 @@ "main": "./bundles/index.umd.js",

@@ -7,7 +7,7 @@ /********************************************************************

* @create: 2022-04-14 15:56:19.960
* @modify: 2022-07-02 10:04:15.377
* @version: 4.2.0
* @times: 17
* @lines: 122
* @copyright: Copyright © 2022 Kaven. All Rights Reserved.
* @modify: 2023-11-30 17:24:59.458
* @version: 4.3.2
* @times: 21
* @lines: 138
* @copyright: Copyright © 2022-2023 Kaven. All Rights Reserved.
* @description: [description]

@@ -17,5 +17,5 @@ * @license: [license]

/**
*
* Represents a utility class for handling and parsing URLs.
* @since 4.0.0
* @version 2022-06-26
* @version 2023-11-30
* @see https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL

@@ -25,3 +25,3 @@ */

readonly OriginalUrl: string;
constructor(url: string);
constructor(url?: string);
Scheme?: string;

@@ -35,3 +35,4 @@ DomainName?: string;

ToString(): string;
TryParse(url: string): boolean;
}
//# sourceMappingURL=KavenUrl.d.ts.map

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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