fix(core): update

This commit is contained in:
Philipp Kunz 2021-01-22 18:27:50 +00:00
parent 76cfc8bec0
commit 48878c0b38
2 changed files with 6 additions and 3 deletions

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