4 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
7 changed files with 4492 additions and 14579 deletions

14567
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smarturl", "name": "@pushrocks/smarturl",
"version": "3.0.4", "version": "3.0.6",
"private": false, "private": false,
"description": "a url parsing lib", "description": "a url parsing lib",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -14,10 +14,11 @@
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.63", "@gitzone/tsbuild": "^2.1.65",
"@gitzone/tstest": "^1.0.72", "@gitzone/tsrun": "^1.2.39",
"@gitzone/tstest": "^1.0.74",
"@pushrocks/tapbundle": "^5.0.4", "@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^18.6.1" "@types/node": "^18.15.11"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
@ -33,6 +34,5 @@
], ],
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
], ]
"dependencies": {}
} }

4457
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -24,9 +24,6 @@ tap.test('should parse an URL', async () => {
tap.test('should parse an URL', async () => { tap.test('should parse an URL', async () => {
const testUrl = 'https://lossless.com:3000/'; const testUrl = 'https://lossless.com:3000/';
// const urlMod = await import('url');
// const altParsed = urlMod.parse(testUrl);
// console.log(altParsed);
const parsedUrl = smarturl.Smarturl.createFromUrl(testUrl, { const parsedUrl = smarturl.Smarturl.createFromUrl(testUrl, {
searchParams: { searchParams: {
more: 'overwritten', more: 'overwritten',
@ -36,4 +33,11 @@ tap.test('should parse an URL', async () => {
console.log(parsedUrl.toString()); 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(); 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

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@pushrocks/smarturl', name: '@pushrocks/smarturl',
version: '3.0.4', version: '3.0.6',
description: 'a url parsing lib' description: 'a url parsing lib'
} }

View File

@ -121,7 +121,9 @@ export class Smarturl implements IUrlObject {
searchParams: ISearchParams; searchParams: ISearchParams;
hash: string; hash: string;
constructor() {} constructor() {
this.searchParams = {};
}
toString() { toString() {
let userpart = ``; let userpart = ``;
@ -133,6 +135,6 @@ export class Smarturl implements IUrlObject {
} }
return `${this.protocol}://${userpart}${this.hostname}:${this.port}/${this.path}`; return `${this.protocol}//${userpart}${this.hostname}:${this.port}${this.path}`;
} }
} }