From c9b40c872595382f63ebc2879f993ed68caa281f Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Thu, 3 Oct 2024 12:49:53 +0200 Subject: [PATCH] fix(core): Fix code formatting and indentation issues in smarturl.classes.smarturl.ts --- changelog.md | 46 +++++++++++++++++++++++++++++++++ ts/00_commitinfo_data.ts | 6 ++--- ts/smarturl.classes.smarturl.ts | 27 ++++++++++++------- 3 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 changelog.md diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..431d92b --- /dev/null +++ b/changelog.md @@ -0,0 +1,46 @@ +# Changelog + +## 2024-10-03 - 3.0.8 - fix(core) +Fix code formatting and indentation issues in smarturl.classes.smarturl.ts + +- Improved code readability by fixing indentation and ensuring consistent formatting. + +## 2022-07-27 - 3.0.0 to 3.0.7 - Core Updates +Maintenance and enhancement updates across multiple minor versions. + +- **3.0.0**: Core updated with foundational changes. +- **3.0.1**: Further core updates with minor fixes. +- **3.0.2**: Continued enhancements and core updates. +- **3.0.3**: Additional core updates. +- **3.0.4**: Continued improvements in core functions. +- **3.0.5**: Ongoing core enhancements and updates. +- **3.0.6**: Maintenance improvements and stable updates. + +## 2022-07-27 - 2.0.2 to 3.0.0 - Major Transition +Introduction of significant changes to the core. + +- **2.0.2**: Introduced breaking changes with a switch to ESM (ECMAScript Modules). + +## 2021-05-02 - 1.0.8 to 2.0.2 - Stability Updates +Updates focused on core stability and functionality. + +- **1.0.8**: Breaking core updates were introduced to stabilize the platform. +- **2.0.0**: Core was updated for greater efficiency. +- **2.0.1**: Minor core improvements and updates. + +## 2021-04-12 - 1.0.3 to 1.0.8 - Core Maintenance +Multiple updates for improving the core functionality. + +- Incremental updates from 1.0.3 through 1.0.7 enhancing core stability. + +## 2020-03-27 - 1.0.1 to 1.0.2 - Initial Core Enhancements +Early updates focusing on core aspects. + +- Introduction of minor core improvements and fixes. + +## 2015-10-21 - 0.0.1 to 0.0.4 - Project Initialization +Initial setup and foundational updates for the project. + +- **0.0.1**: Project initiation and Travis integration. +- **0.0.3**: Creation of initial test infrastructure. +- **0.0.4**: Basic project setup completed. \ No newline at end of file diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 089bf04..8d37a3a 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -1,8 +1,8 @@ /** - * autocreated commitinfo by @pushrocks/commitinfo + * autocreated commitinfo by @push.rocks/commitinfo */ export const commitinfo = { name: '@push.rocks/smarturl', - version: '3.0.7', - description: 'a url parsing lib' + version: '3.0.8', + description: 'A library for parsing URLs in a detailed and flexible way.' } diff --git a/ts/smarturl.classes.smarturl.ts b/ts/smarturl.classes.smarturl.ts index deb2d65..699438c 100644 --- a/ts/smarturl.classes.smarturl.ts +++ b/ts/smarturl.classes.smarturl.ts @@ -34,18 +34,18 @@ export class Smarturl implements IUrlObject { const searchParamPairs: { key: string; value: string; - }[] = [] + }[] = []; if (parsedUrlInstance.search) { parsedUrlInstance.search - .replace('?', '') - .split('&') - .map((searchParamPair) => { - searchParamPairs.push({ - key: searchParamPair.split('=')[0], - value: searchParamPair.split('=')[1], + .replace('?', '') + .split('&') + .map((searchParamPair) => { + searchParamPairs.push({ + key: searchParamPair.split('=')[0], + value: searchParamPair.split('=')[1], + }); }); - }); } for (const searchParamPair of searchParamPairs) { @@ -100,6 +100,7 @@ export class Smarturl implements IUrlObject { Object.assign(returnSmarturl, parsedUrl); return returnSmarturl; } + public static createFromParsedUrl(parsedUrlArg: IUrlObject) { const returnSmarturl = new Smarturl(); Object.assign(returnSmarturl, parsedUrlArg); @@ -125,6 +126,13 @@ export class Smarturl implements IUrlObject { this.searchParams = {}; } + clone(): Smarturl { + const clonedInstance = new Smarturl(); + Object.assign(clonedInstance, this); + clonedInstance.searchParams = { ...this.searchParams }; + return clonedInstance; + } + toString() { let userpart = ``; if (this.username && !this.password) { @@ -134,7 +142,6 @@ export class Smarturl implements IUrlObject { userpart = `${this.username}:${this.password}@`; } - return `${this.protocol}//${userpart}${this.hostname}:${this.port}${this.path}`; } -} +} \ No newline at end of file