Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
76cfc8bec0 | |||
7f3118c525 | |||
9d189d1b59 | |||
0266afca8e | |||
bef836fc83 | |||
2bd1741893 |
11
package-lock.json
generated
11
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartstring",
|
||||
"version": "3.0.20",
|
||||
"version": "3.0.23",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -3927,7 +3927,6 @@
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://verdaccio.lossless.one/crypto-random-string/-/crypto-random-string-3.3.0.tgz",
|
||||
"integrity": "sha512-teWAwfMb1d6brahYyKqcBEb5Yp8PJPvPOdOonXDnvaKOTmKDFNVE8E3Y2XQuzjNV/3XMwHbrX9fHWvrhRKt4Gg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"type-fest": "^0.8.1"
|
||||
}
|
||||
@ -7528,11 +7527,6 @@
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"nanoid": {
|
||||
"version": "3.1.20",
|
||||
"resolved": "https://verdaccio.lossless.one/nanoid/-/nanoid-3.1.20.tgz",
|
||||
"integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw=="
|
||||
},
|
||||
"nanomatch": {
|
||||
"version": "1.2.13",
|
||||
"resolved": "https://verdaccio.lossless.one/nanomatch/-/nanomatch-1.2.13.tgz",
|
||||
@ -10490,8 +10484,7 @@
|
||||
"type-fest": {
|
||||
"version": "0.8.1",
|
||||
"resolved": "https://verdaccio.lossless.one/type-fest/-/type-fest-0.8.1.tgz",
|
||||
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA=="
|
||||
},
|
||||
"type-is": {
|
||||
"version": "1.6.18",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartstring",
|
||||
"version": "3.0.20",
|
||||
"version": "3.0.23",
|
||||
"private": false,
|
||||
"description": "handle strings in smart ways. TypeScript ready.",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -34,8 +34,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartenv": "^4.0.16",
|
||||
"crypto-random-string": "^3.3.0",
|
||||
"js-base64": "^2.5.1",
|
||||
"nanoid": "^3.1.20",
|
||||
"normalize-newline": "^3.0.0",
|
||||
"randomatic": "^3.1.1",
|
||||
"strip-indent": "^3.0.0",
|
||||
|
@ -29,4 +29,9 @@ tap.test('testDomain2 expect be a basic domain', async () => {
|
||||
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);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -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
|
||||
*/
|
||||
export const createCryptoRandomString = (lengthArg: number): string => {
|
||||
return plugins.nanoid(lengthArg);
|
||||
return plugins.cryptoRandomString(lengthArg);
|
||||
};
|
||||
|
@ -16,7 +16,12 @@ export class Domain {
|
||||
public port;
|
||||
public nodeParsedUrl: plugins.url.UrlWithStringQuery;
|
||||
constructor(domainStringArg: string) {
|
||||
const regexMatches = this._domainRegex(domainStringArg);
|
||||
// lets do the node standard stuff first
|
||||
this.nodeParsedUrl = plugins.url.parse(domainStringArg);
|
||||
this.port = this.nodeParsedUrl.port;
|
||||
|
||||
// lets do the rest after
|
||||
const regexMatches = this._domainRegex(domainStringArg.replace(this.nodeParsedUrl.path, ''));
|
||||
this.fullName = '';
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
if (regexMatches[i - 1]) {
|
||||
@ -38,9 +43,6 @@ export class Domain {
|
||||
this.topLevel = this.level1;
|
||||
this.domainName = this.level2;
|
||||
this.subDomain = this.level3;
|
||||
|
||||
this.nodeParsedUrl = plugins.url.parse(domainStringArg);
|
||||
this.port = this.nodeParsedUrl.port;
|
||||
}
|
||||
|
||||
// helper functions
|
||||
|
@ -12,14 +12,7 @@ const jsBase64 = require('js-base64').Base64;
|
||||
|
||||
const stripIndent = require('strip-indent');
|
||||
const normalizeNewline = require('normalize-newline');
|
||||
const randomatic = require('randomatic');
|
||||
const randomatic = smartenvInstance.getSafeNodeModule('randomatic');
|
||||
const cryptoRandomString = smartenvInstance.getSafeNodeModule('crypto-random-string');
|
||||
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
export {
|
||||
jsBase64,
|
||||
stripIndent,
|
||||
normalizeNewline,
|
||||
randomatic,
|
||||
nanoid
|
||||
}
|
||||
export { jsBase64, stripIndent, normalizeNewline, randomatic, cryptoRandomString };
|
||||
|
Reference in New Issue
Block a user