18 Commits

Author SHA1 Message Date
08d5627e7e 3.0.6 2023-04-17 14:41:24 +02:00
25a8b750d8 fix(core): update 2023-04-17 14:41:23 +02:00
5eaa7ea0c3 3.0.5 2022-08-21 13:56:35 +02:00
d255c598b4 fix(core): update 2022-08-21 13:56:34 +02:00
5bb01a2db9 3.0.4 2022-08-06 22:28:16 +02:00
44b1e67302 fix(core): update 2022-08-06 22:28:16 +02:00
b1162191c6 3.0.3 2022-08-06 22:17:41 +02:00
60f1368071 fix(core): update 2022-08-06 22:17:41 +02:00
1c503ec655 3.0.2 2022-07-28 15:10:34 +02:00
2d52a14ec1 fix(core): update 2022-07-28 15:10:34 +02:00
55894a30f2 3.0.1 2022-07-27 01:06:17 +02:00
249c50a3c5 fix(core): update 2022-07-27 01:06:16 +02:00
6470b05152 3.0.0 2022-07-27 00:40:46 +02:00
cfe189b02f BREAKING CHANGE(core): switch to esm 2022-07-27 00:40:46 +02:00
f3e9f49af2 2.0.2 2022-07-27 00:40:18 +02:00
4b6dc9f5c3 fix(core): update 2022-07-27 00:40:18 +02:00
b84c8053ff 2.0.1 2021-05-02 16:33:50 +00:00
544f309dc9 fix(core): update 2021-05-02 16:33:50 +00:00
15 changed files with 4599 additions and 11964 deletions

View File

@ -12,20 +12,12 @@ stages:
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
@ -36,6 +28,7 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
@ -96,10 +89,9 @@ codequality:
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
@ -119,11 +111,10 @@ trigger:
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci node install stable
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
- npmci command npm run buildDocs
tags:
- lossless
- docker

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
"type": "node-terminal"
}
]
}

View File

@ -5,7 +5,7 @@
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smarturl",
"shortDescription": "a url parsing lib",
"description": "a url parsing lib",
"npmPackagename": "@pushrocks/smarturl",
"license": "MIT",
"projectDomain": "push.rocks"

11860
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,25 @@
{
"name": "@pushrocks/smarturl",
"version": "2.0.0",
"version": "3.0.6",
"private": false,
"description": "a url parsing lib",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)"
"build": "(tsbuild --web)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^14.14.37",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
"@gitzone/tsbuild": "^2.1.65",
"@gitzone/tsrun": "^1.2.39",
"@gitzone/tstest": "^1.0.74",
"@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^18.15.11"
},
"dependencies": {},
"files": [
"ts/**/*",
"ts_web/**/*",

4457
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

43
test/test.both.ts Normal file
View File

@ -0,0 +1,43 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smarturl from '../ts/index.js';
let testSmarturl: smarturl.Smarturl;
tap.test('first test', async () => {
testSmarturl = new smarturl.Smarturl();
expect(testSmarturl).toBeInstanceOf(smarturl.Smarturl);
});
tap.test('should parse an URL', async () => {
const testUrl = 'https://lossless.com:3000/?some=cool&more=yes';
// const urlMod = await import('url');
// const altParsed = urlMod.parse(testUrl);
// console.log(altParsed);
const parsedUrl = smarturl.Smarturl.createFromUrl(testUrl, {
searchParams: {
more: 'overwritten',
},
});
console.log(parsedUrl);
console.log(parsedUrl.toString());
});
tap.test('should parse an URL', async () => {
const testUrl = 'https://lossless.com:3000/';
const parsedUrl = smarturl.Smarturl.createFromUrl(testUrl, {
searchParams: {
more: 'overwritten',
},
});
console.log(parsedUrl);
console.log(parsedUrl.toString());
});
tap.test('should correctly parse ans assemble urls', async () => {
const testUrl = 'https://lossless.com/';
const parsedUrl = smarturl.Smarturl.createFromUrl(testUrl, {});
console.log(parsedUrl.toString());
expect(parsedUrl.toString()).toEqual('https://lossless.com:443/');
});
tap.start();

View File

@ -0,0 +1,17 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smarturl from '../ts/index.js';
let testSmarturl: smarturl.Smarturl;
tap.test('first test', async () => {
testSmarturl = new smarturl.Smarturl();
expect(testSmarturl).toBeInstanceOf(smarturl.Smarturl);
});
tap.test('should create searchParams only', async () => {
const smarturlInstance = new smarturl.Smarturl();
smarturlInstance.searchParams['hello'] = 'hi_there';
console.log(smarturlInstance.toString());
})
tap.start();

View File

@ -1,25 +0,0 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smarturl from '../ts/index';
let testSmarturl: smarturl.Smarturl;
tap.test('first test', async () => {
testSmarturl = new smarturl.Smarturl();
expect(testSmarturl).to.be.instanceOf(smarturl.Smarturl);
});
tap.test('should parse an URL', async () => {
const testUrl = 'https://lossless.com:3000/?some=cool&more=yes';
// const urlMod = await import('url');
// const altParsed = urlMod.parse(testUrl);
// console.log(altParsed);
const parsedUrl = smarturl.Smarturl.createFromUrl(testUrl, {
searchParams: {
more: 'overwritten'
}
});
console.log(parsedUrl);
console.log(parsedUrl.toString());
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smarturl',
version: '3.0.6',
description: 'a url parsing lib'
}

View File

@ -1 +1 @@
export * from './smarturl.classes.smarturl';
export * from './smarturl.classes.smarturl.js';

View File

@ -1,4 +1,4 @@
import * as plugins from './smarturl.plugins';
import * as plugins from './smarturl.plugins.js';
export interface IUrlObject {
href: string;
@ -27,13 +27,29 @@ export class Smarturl implements IUrlObject {
searchParams?: ISearchParams;
}
): Smarturl {
const parsedUrlInstance = new plugins.url.URL(urlArg);
const parsedUrlInstance = new URL(urlArg);
const searchParams: ISearchParams = {};
// enrichment
const searchParamKeys = parsedUrlInstance.searchParams.keys();
for (const key of searchParamKeys) {
searchParams[key] = parsedUrlInstance.searchParams.get(key);
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],
});
});
}
for (const searchParamPair of searchParamPairs) {
searchParams[searchParamPair.key] = searchParamPair.value;
}
if (optionsArg?.searchParams) {
for (const key of Object.keys(optionsArg.searchParams)) {
@ -41,11 +57,11 @@ export class Smarturl implements IUrlObject {
}
}
let path = parsedUrlInstance.pathname;
let path = parsedUrlInstance.pathname || '';
if (Object.keys(searchParams).length > 0) {
path += '?';
let first = true;
for(const key of Object.keys(searchParams)) {
for (const key of Object.keys(searchParams)) {
if (first) {
first = false;
} else {
@ -56,6 +72,7 @@ export class Smarturl implements IUrlObject {
}
const parsedUrl: IUrlObject = {
...parsedUrlInstance,
href: parsedUrlInstance.href,
origin: parsedUrlInstance.origin,
protocol: parsedUrlInstance.protocol,
@ -83,7 +100,11 @@ export class Smarturl implements IUrlObject {
Object.assign(returnSmarturl, parsedUrl);
return returnSmarturl;
}
public static createFromParsedUrl() {}
public static createFromParsedUrl(parsedUrlArg: IUrlObject) {
const returnSmarturl = new Smarturl();
Object.assign(returnSmarturl, parsedUrlArg);
return returnSmarturl;
}
// INSTANCE
href: string;
@ -100,9 +121,20 @@ export class Smarturl implements IUrlObject {
searchParams: ISearchParams;
hash: string;
constructor() {}
constructor() {
this.searchParams = {};
}
toString() {
return `${this.protocol}//${this.hostname}:${this.port}${this.path}`
let userpart = ``;
if (this.username && !this.password) {
userpart = `${this.username}@`;
}
if (this.username && this.password) {
userpart = `${this.username}:${this.password}@`;
}
return `${this.protocol}//${userpart}${this.hostname}:${this.port}${this.path}`;
}
}

View File

@ -1,4 +1 @@
// node native
import * as url from 'url';
export { url };
export {};

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true,
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}