Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
76cfc8bec0 | |||
7f3118c525 | |||
9d189d1b59 | |||
0266afca8e | |||
bef836fc83 | |||
2bd1741893 | |||
bd20512b10 | |||
25d0ba8036 |
16
package-lock.json
generated
16
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartstring",
|
"name": "@pushrocks/smartstring",
|
||||||
"version": "3.0.19",
|
"version": "3.0.23",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -7527,12 +7527,6 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"nanoid": {
|
|
||||||
"version": "2.1.11",
|
|
||||||
"resolved": "https://verdaccio.lossless.one/nanoid/-/nanoid-2.1.11.tgz",
|
|
||||||
"integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"nanomatch": {
|
"nanomatch": {
|
||||||
"version": "1.2.13",
|
"version": "1.2.13",
|
||||||
"resolved": "https://verdaccio.lossless.one/nanomatch/-/nanomatch-1.2.13.tgz",
|
"resolved": "https://verdaccio.lossless.one/nanomatch/-/nanomatch-1.2.13.tgz",
|
||||||
@ -9625,6 +9619,14 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"nanoid": "^2.1.0"
|
"nanoid": "^2.1.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"nanoid": {
|
||||||
|
"version": "2.1.11",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/nanoid/-/nanoid-2.1.11.tgz",
|
||||||
|
"integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"signal-exit": {
|
"signal-exit": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartstring",
|
"name": "@pushrocks/smartstring",
|
||||||
"version": "3.0.19",
|
"version": "3.0.23",
|
||||||
"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",
|
||||||
|
@ -29,4 +29,9 @@ tap.test('testDomain2 expect be a basic domain', async () => {
|
|||||||
console.log(testDomain2);
|
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();
|
tap.start();
|
||||||
|
@ -16,7 +16,12 @@ 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.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 = '';
|
this.fullName = '';
|
||||||
for (let i = 1; i <= 5; i++) {
|
for (let i = 1; i <= 5; i++) {
|
||||||
if (regexMatches[i - 1]) {
|
if (regexMatches[i - 1]) {
|
||||||
@ -38,9 +43,6 @@ export class Domain {
|
|||||||
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
|
||||||
|
@ -8,9 +8,11 @@ import * as url from 'url';
|
|||||||
export { crypto, url };
|
export { crypto, url };
|
||||||
|
|
||||||
// third party
|
// third party
|
||||||
export let jsBase64 = require('js-base64').Base64;
|
const jsBase64 = require('js-base64').Base64;
|
||||||
|
|
||||||
export let stripIndent = require('strip-indent');
|
const stripIndent = require('strip-indent');
|
||||||
export let normalizeNewline = require('normalize-newline');
|
const normalizeNewline = require('normalize-newline');
|
||||||
export let randomatic = require('randomatic');
|
const randomatic = smartenvInstance.getSafeNodeModule('randomatic');
|
||||||
export let cryptoRandomString = require('crypto-random-string');
|
const cryptoRandomString = smartenvInstance.getSafeNodeModule('crypto-random-string');
|
||||||
|
|
||||||
|
export { jsBase64, stripIndent, normalizeNewline, randomatic, cryptoRandomString };
|
||||||
|
Reference in New Issue
Block a user