Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
76cfc8bec0 | |||
7f3118c525 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartstring",
|
"name": "@pushrocks/smartstring",
|
||||||
"version": "3.0.22",
|
"version": "3.0.23",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartstring",
|
"name": "@pushrocks/smartstring",
|
||||||
"version": "3.0.22",
|
"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
|
||||||
|
@ -15,10 +15,4 @@ const normalizeNewline = require('normalize-newline');
|
|||||||
const randomatic = smartenvInstance.getSafeNodeModule('randomatic');
|
const randomatic = smartenvInstance.getSafeNodeModule('randomatic');
|
||||||
const cryptoRandomString = smartenvInstance.getSafeNodeModule('crypto-random-string');
|
const cryptoRandomString = smartenvInstance.getSafeNodeModule('crypto-random-string');
|
||||||
|
|
||||||
export {
|
export { jsBase64, stripIndent, normalizeNewline, randomatic, cryptoRandomString };
|
||||||
jsBase64,
|
|
||||||
stripIndent,
|
|
||||||
normalizeNewline,
|
|
||||||
randomatic,
|
|
||||||
cryptoRandomString
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user