Compare commits

...

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

2
package-lock.json generated
View File

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

View File

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

View File

@ -25,7 +25,7 @@ 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);
});

View File

@ -17,11 +17,15 @@ export class Domain {
public nodeParsedUrl: plugins.url.UrlWithStringQuery;
constructor(domainStringArg: string) {
// 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.path, ''));
const regexMatches = this._domainRegex(domainStringArg.replace(this.nodeParsedUrl.pathname, ''));
this.fullName = '';
for (let i = 1; i <= 5; i++) {
if (regexMatches[i - 1]) {
@ -36,7 +40,6 @@ export class Domain {
this['level' + i.toString()] = undefined;
}
}
this.protocol = this._protocolRegex(domainStringArg);
this.zoneName = this.level2 + '.' + this.level1;
// aliases