Compare commits

...

4 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
5 changed files with 19 additions and 15 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartstring",
"version": "3.0.22",
"version": "3.0.24",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartstring",
"version": "3.0.22",
"version": "3.0.24",
"private": false,
"description": "handle strings in smart ways. TypeScript ready.",
"main": "dist_ts/index.js",

View File

@ -25,7 +25,12 @@ tap.test('expect have the correct protocol', async () => {
expect(testDomain.protocol).equal('https');
});
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);
});

View File

@ -16,7 +16,16 @@ 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.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 = '';
for (let i = 1; i <= 5; i++) {
if (regexMatches[i - 1]) {
@ -31,16 +40,12 @@ export class Domain {
this['level' + i.toString()] = undefined;
}
}
this.protocol = this._protocolRegex(domainStringArg);
this.zoneName = this.level2 + '.' + this.level1;
// aliases
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

View File

@ -15,10 +15,4 @@ const normalizeNewline = require('normalize-newline');
const randomatic = smartenvInstance.getSafeNodeModule('randomatic');
const cryptoRandomString = smartenvInstance.getSafeNodeModule('crypto-random-string');
export {
jsBase64,
stripIndent,
normalizeNewline,
randomatic,
cryptoRandomString
}
export { jsBase64, stripIndent, normalizeNewline, randomatic, cryptoRandomString };