21 Commits

Author SHA1 Message Date
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
f6e6697244 2.0.0 2021-05-02 16:32:25 +00:00
ce6622f858 BREAKING CHANGE(core): update 2021-05-02 16:32:24 +00:00
105b1ca637 1.0.8 2021-04-13 08:10:11 +00:00
546c7806bc fix(core): update 2021-04-13 08:10:09 +00:00
d446575e60 1.0.7 2021-04-12 20:09:54 +00:00
31922529ae fix(core): update 2021-04-12 20:09:53 +00:00
fced2e845e 1.0.6 2021-04-12 20:09:20 +00:00
c7169e37a6 fix(core): update 2021-04-12 20:09:19 +00:00
04a62f6176 1.0.5 2021-04-12 19:41:03 +00:00
ea9b67a328 fix(core): update 2021-04-12 19:41:03 +00:00
dbb62a819a 1.0.4 2021-04-12 19:34:01 +00:00
9381533066 1.0.3 2021-04-12 19:18:36 +00:00
4d966147c4 fix(core): update 2021-04-12 19:18:36 +00:00
14 changed files with 14108 additions and 730 deletions

View File

@ -12,30 +12,35 @@ stages:
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
mirror:
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci git mirror
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- lossless
- docker
- notpriv
allow_failure: true
audit:
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high
- npmci command npm audit --audit-level=high --only=dev
tags:
- lossless
- docker
- notpriv
allow_failure: true
# ====================
# test stage
@ -50,9 +55,7 @@ testStable:
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- priv
testBuild:
stage: test
@ -63,9 +66,7 @@ testBuild:
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- notpriv
release:
stage: release
@ -85,11 +86,12 @@ release:
codequality:
stage: metadata
allow_failure: true
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
@ -109,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

@ -15,7 +15,7 @@
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm"]
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}

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"

14539
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +1,24 @@
{
"name": "@pushrocks/smarturl",
"version": "1.0.2",
"version": "3.0.1",
"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/)",
"build": "(tsbuild)",
"format": "(gitzone format)"
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.11.7",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
"@gitzone/tsbuild": "^2.1.63",
"@gitzone/tstest": "^1.0.72",
"@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^18.6.1"
},
"dependencies": {},
"files": [
"ts/**/*",
"ts_web/**/*",
@ -32,5 +30,11 @@
"cli.js",
"npmextra.json",
"readme.md"
]
],
"browserslist": [
"last 1 chrome versions"
],
"dependencies": {
"parse-url": "^6.0.5"
}
}

View File

@ -8,13 +8,20 @@ a url parsing lib
* [docs (typedoc)](https://pushrocks.gitlab.io/smarturl/)
## Status for master
[![pipeline status](https://gitlab.com/pushrocks/smarturl/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/smarturl/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smarturl/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smarturl/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smarturl.svg)](https://www.npmjs.com/package/@pushrocks/smarturl)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smarturl/badge.svg)](https://snyk.io/test/npm/@pushrocks/smarturl)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smarturl/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smarturl/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smarturl)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smarturl)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smarturl)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smarturl)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smarturl)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage

View File

@ -1,8 +1,25 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smarturl from '../ts/index';
import * as smarturl from '../ts/index.js';
let testSmarturl: smarturl.Smarturl;
tap.test('first test', async () => {
console.log(smarturl.standardExport);
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.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.1',
description: 'a url parsing lib'
}

View File

@ -1,3 +1 @@
import * as plugins from './smarturl.plugins';
export let standardExport = 'Hi there! :) This is an exported string';
export * from './smarturl.classes.smarturl.js';

View File

@ -0,0 +1,121 @@
import * as plugins from './smarturl.plugins.js';
export interface IUrlObject {
href: string;
origin: string;
protocol: string;
username: string;
password: string;
host: string;
hostname: string;
port: string;
path: string;
pathname: string;
search: string;
searchParams: ISearchParams;
hash: string;
}
export interface ISearchParams {
[key: string]: string;
}
export class Smarturl implements IUrlObject {
public static createFromUrl(
urlArg: string,
optionsArg?: {
searchParams?: ISearchParams;
}
): Smarturl {
const parsedUrlInstance = plugins.url(urlArg);
const searchParams: ISearchParams = {};
// enrichment
const searchParamPairs = parsedUrlInstance.search
.replace('?', '')
.split('&')
.map((searchParamPair) => {
return {
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)) {
searchParams[key] = optionsArg.searchParams[key];
}
}
let path = parsedUrlInstance.pathname;
if (Object.keys(searchParams).length > 0) {
path += '?';
let first = true;
for (const key of Object.keys(searchParams)) {
if (first) {
first = false;
} else {
path += '&';
}
path += `${key}=${searchParams[key]}`;
}
}
const parsedUrl: IUrlObject = {
href: parsedUrlInstance.href,
origin: `${parsedUrlInstance.protocol}://${parsedUrlInstance.resource}`,
protocol: parsedUrlInstance.protocol,
username: parsedUrlInstance.user.split(':')[0],
password: parsedUrlInstance.user.split(':')[1] || '',
host: `${parsedUrlInstance.resource}:${parsedUrlInstance.port}`,
hostname: parsedUrlInstance.resource,
port: parsedUrlInstance.port,
path,
pathname: parsedUrlInstance.pathname,
search: parsedUrlInstance.search,
searchParams,
hash: parsedUrlInstance.hash,
};
if (!parsedUrl.port && parsedUrl.protocol === 'https:') {
// console.log(`inferring port 443 for "https:"`);
parsedUrl.port = '443';
}
if (!parsedUrl.port && parsedUrl.protocol === 'http:') {
// console.log(`inferring port 80 for "http:"`);
parsedUrl.port = '80';
}
const returnSmarturl = new Smarturl();
Object.assign(returnSmarturl, parsedUrl);
return returnSmarturl;
}
public static createFromParsedUrl(parsedUrlArg: IUrlObject) {
const returnSmarturl = new Smarturl();
Object.assign(returnSmarturl, parsedUrlArg);
return returnSmarturl;
}
// INSTANCE
href: string;
origin: string;
protocol: string;
username: string;
password: string;
host: string;
hostname: string;
port: string;
path: string;
pathname: string;
search: string;
searchParams: ISearchParams;
hash: string;
constructor() {}
toString() {
return `${this.protocol}//${this.hostname}:${this.port}${this.path}`;
}
}

View File

@ -1,2 +1,4 @@
const removeme = {};
export { removeme };
// node native
import { default as url } from 'parse-url';
export { url };

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"
}