Compare commits

...

6 Commits

Author SHA1 Message Date
8b1769d65e 3.0.24 2021-01-22 18:27:51 +00:00
48878c0b38 fix(core): update 2021-01-22 18:27:50 +00:00
76cfc8bec0 3.0.23 2021-01-22 14:46:04 +00:00
7f3118c525 fix(core): update 2021-01-22 14:46:02 +00:00
9d189d1b59 3.0.22 2020-12-31 04:42:47 +00:00
0266afca8e fix(core): update 2020-12-31 04:42:46 +00:00
6 changed files with 29 additions and 33 deletions

9
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartstring", "name": "@pushrocks/smartstring",
"version": "3.0.21", "version": "3.0.24",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1350,7 +1350,8 @@
"@pushrocks/isounique": { "@pushrocks/isounique": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fisounique/-/isounique-1.0.4.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fisounique/-/isounique-1.0.4.tgz",
"integrity": "sha512-P1xLsuA1+8LQpoWCo2nP2vIQXKGUl5wDWU6CD7xTDZc3uw0He5V/qCPHM5zpIZsS7IuZOxDDpWb7aFveB11tXw==" "integrity": "sha512-P1xLsuA1+8LQpoWCo2nP2vIQXKGUl5wDWU6CD7xTDZc3uw0He5V/qCPHM5zpIZsS7IuZOxDDpWb7aFveB11tXw==",
"dev": true
}, },
"@pushrocks/lik": { "@pushrocks/lik": {
"version": "4.0.20", "version": "4.0.20",
@ -3926,7 +3927,6 @@
"version": "3.3.0", "version": "3.3.0",
"resolved": "https://verdaccio.lossless.one/crypto-random-string/-/crypto-random-string-3.3.0.tgz", "resolved": "https://verdaccio.lossless.one/crypto-random-string/-/crypto-random-string-3.3.0.tgz",
"integrity": "sha512-teWAwfMb1d6brahYyKqcBEb5Yp8PJPvPOdOonXDnvaKOTmKDFNVE8E3Y2XQuzjNV/3XMwHbrX9fHWvrhRKt4Gg==", "integrity": "sha512-teWAwfMb1d6brahYyKqcBEb5Yp8PJPvPOdOonXDnvaKOTmKDFNVE8E3Y2XQuzjNV/3XMwHbrX9fHWvrhRKt4Gg==",
"dev": true,
"requires": { "requires": {
"type-fest": "^0.8.1" "type-fest": "^0.8.1"
} }
@ -10484,8 +10484,7 @@
"type-fest": { "type-fest": {
"version": "0.8.1", "version": "0.8.1",
"resolved": "https://verdaccio.lossless.one/type-fest/-/type-fest-0.8.1.tgz", "resolved": "https://verdaccio.lossless.one/type-fest/-/type-fest-0.8.1.tgz",
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA=="
"dev": true
}, },
"type-is": { "type-is": {
"version": "1.6.18", "version": "1.6.18",

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartstring", "name": "@pushrocks/smartstring",
"version": "3.0.21", "version": "3.0.24",
"private": false, "private": false,
"description": "handle strings in smart ways. TypeScript ready.", "description": "handle strings in smart ways. TypeScript ready.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -33,8 +33,8 @@
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/isounique": "^1.0.4",
"@pushrocks/smartenv": "^4.0.16", "@pushrocks/smartenv": "^4.0.16",
"crypto-random-string": "^3.3.0",
"js-base64": "^2.5.1", "js-base64": "^2.5.1",
"normalize-newline": "^3.0.0", "normalize-newline": "^3.0.0",
"randomatic": "^3.1.1", "randomatic": "^3.1.1",

View File

@ -25,7 +25,12 @@ tap.test('expect have the correct protocol', async () => {
expect(testDomain.protocol).equal('https'); expect(testDomain.protocol).equal('https');
}); });
tap.test('testDomain2 expect be a basic domain', async () => { tap.test('testDomain2 expect be a basic domain', async () => {
testDomain2 = new smartstring.Domain('bleu.de'); testDomain2 = new smartstring.Domain('testing.bleu.de');
console.log(testDomain2);
});
tap.test('should parse complex domains', async () => {
testDomain2 = new smartstring.Domain('https://sub1.sub2.lossless.com/some/path:5431');
console.log(testDomain2); console.log(testDomain2);
}); });

View File

@ -21,9 +21,9 @@ export const createRandomString = (
}; };
/** /**
* creates a cryptic string in the speicifed length * creates a crytic string in the speicifed length
* @param lengthArg the length of the crypto string * @param lengthArg the length of the crypto string
*/ */
export const createCryptoRandomString = (lengthArg: number): string => { export const createCryptoRandomString = (lengthArg: number): string => {
return plugins.isounique.uni(); return plugins.cryptoRandomString(lengthArg);
}; };

View File

@ -16,7 +16,16 @@ export class Domain {
public port; public port;
public nodeParsedUrl: plugins.url.UrlWithStringQuery; public nodeParsedUrl: plugins.url.UrlWithStringQuery;
constructor(domainStringArg: string) { constructor(domainStringArg: string) {
const regexMatches = this._domainRegex(domainStringArg); // lets do the node standard stuff first
this.protocol = this._protocolRegex(domainStringArg);
if (!this.protocol) {
domainStringArg = `https://${domainStringArg}`
}
this.nodeParsedUrl = plugins.url.parse(domainStringArg);
this.port = this.nodeParsedUrl.port;
// lets do the rest after
const regexMatches = this._domainRegex(domainStringArg.replace(this.nodeParsedUrl.pathname, ''));
this.fullName = ''; this.fullName = '';
for (let i = 1; i <= 5; i++) { for (let i = 1; i <= 5; i++) {
if (regexMatches[i - 1]) { if (regexMatches[i - 1]) {
@ -31,16 +40,12 @@ export class Domain {
this['level' + i.toString()] = undefined; this['level' + i.toString()] = undefined;
} }
} }
this.protocol = this._protocolRegex(domainStringArg);
this.zoneName = this.level2 + '.' + this.level1; this.zoneName = this.level2 + '.' + this.level1;
// aliases // aliases
this.topLevel = this.level1; this.topLevel = this.level1;
this.domainName = this.level2; this.domainName = this.level2;
this.subDomain = this.level3; this.subDomain = this.level3;
this.nodeParsedUrl = plugins.url.parse(domainStringArg);
this.port = this.nodeParsedUrl.port;
} }
// helper functions // helper functions

View File

@ -1,31 +1,18 @@
// node native
import * as smartenv from '@pushrocks/smartenv'; import * as smartenv from '@pushrocks/smartenv';
const smartenvInstance = new smartenv.Smartenv(); const smartenvInstance = new smartenv.Smartenv();
// node native
const crypto = smartenvInstance.getSafeNodeModule('crypto'); const crypto = smartenvInstance.getSafeNodeModule('crypto');
import * as url from 'url'; import * as url from 'url';
export { crypto, url }; export { crypto, url };
// pushrocks scope
import * as isounique from '@pushrocks/isounique';
export {
isounique
};
// third party // third party
const jsBase64 = require('js-base64').Base64; const jsBase64 = require('js-base64').Base64;
const stripIndent = require('strip-indent'); const stripIndent = require('strip-indent');
const normalizeNewline = require('normalize-newline'); const normalizeNewline = require('normalize-newline');
const randomatic = require('randomatic'); const randomatic = smartenvInstance.getSafeNodeModule('randomatic');
const cryptoRandomString = smartenvInstance.getSafeNodeModule('crypto-random-string');
export { jsBase64, stripIndent, normalizeNewline, randomatic, cryptoRandomString };
export {
jsBase64,
stripIndent,
normalizeNewline,
randomatic,
}