now computes zoneName and finds protocol

This commit is contained in:
Philipp Kunz 2016-05-25 06:54:55 +02:00
parent 05cd515824
commit 2d4c480c1b
5 changed files with 37 additions and 5 deletions

View File

@ -7,6 +7,7 @@ export declare class Domain {
level4: string; level4: string;
level5: string; level5: string;
protocol: string; protocol: string;
zoneName: string;
topLevel: string; topLevel: string;
domainName: any; domainName: any;
subDomain: any; subDomain: any;

View File

@ -9,6 +9,8 @@ var Domain = (function () {
this.level3 = regexMatches[2]; this.level3 = regexMatches[2];
this.level4 = regexMatches[3]; this.level4 = regexMatches[3];
this.level5 = regexMatches[4]; this.level5 = regexMatches[4];
this.protocol = protocolRegex(domainStringArg)[1];
this.zoneName = this.level2 + "." + this.level1;
// aliases // aliases
this.topLevel = this.level1; this.topLevel = this.level1;
this.domainName = this.level2; this.domainName = this.level2;
@ -26,5 +28,11 @@ var domainRegex = function (stringArg) {
}); });
return regexMatchesFiltered; return regexMatchesFiltered;
}; };
var protocolRegex = function (stringArg) {
var regexString = /^([a-zA-Z0-9]*):\/\//;
var regexMatches = regexString.exec(stringArg);
console.log(regexMatches);
return regexMatches;
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLmRvbWFpbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFDUCxDQUFDLENBRHNCO0FBR3ZCO0lBWUksZ0JBQVksZUFBc0I7UUFDOUIsSUFBSSxDQUFDLFFBQVEsR0FBRyxlQUFlLENBQUM7UUFDaEMsSUFBSSxZQUFZLEdBQUcsV0FBVyxDQUFDLGVBQWUsQ0FBQyxDQUFDO1FBQ2hELElBQUksQ0FBQyxNQUFNLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzlCLElBQUksQ0FBQyxNQUFNLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzlCLElBQUksQ0FBQ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1cm4oc3RyaW5nQXJnICE9IFwiXCIpO1xyXG4gICAgfSk7XHJcbiAgICByZXR1cm4gcmVnZXhNYXRjaGVzRmlsdGVyZWQ7XHJcbn07XHJcblxyXG5sZXQgcHJvdG9jb2xSZWdleCA9IGZ1bmN0aW9uKHN0cmluZ0FyZzpzdHJpbmcpe1xyXG4gICAgbGV0IHJlZ2V4U3RyaW5nID0gL14oW2EtekEtWjAtOV0qKTpcXC9cXC8vO1xyXG4gICAgbGV0IHJlZ2V4TWF0Y2hlcyA9IHJlZ2V4U3RyaW5nLmV4ZWMoc3RyaW5nQXJnKTtcclxuICAgIGNvbnNvbGUubG9nKHJlZ2V4TWF0Y2hlcyk7XHJcbiAgICByZXR1cm4gcmVnZXhNYXRjaGVzO1xyXG59Il19

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,7 @@ describe("smartstring",function(){
describe(".Domain class",function(){ describe(".Domain class",function(){
let testDomain:smartstring.Domain; let testDomain:smartstring.Domain;
it("should create a new Domain object",function(){ it("should create a new Domain object",function(){
testDomain = new smartstring.Domain("level3D.level2D.level1D"); testDomain = new smartstring.Domain("https://level3D.level2D.level1D");
testDomain.should.be.instanceof(smartstring.Domain); testDomain.should.be.instanceof(smartstring.Domain);
}); });
it("should have a .topLevel",function(){ it("should have a .topLevel",function(){
@ -18,6 +18,12 @@ describe("smartstring",function(){
it("should have a .level3",function(){ it("should have a .level3",function(){
testDomain.level3.should.equal("level3D"); testDomain.level3.should.equal("level3D");
}); });
it("should have the correct dns zone name",function(){
testDomain.zoneName.should.equal("level2D.level1D");
})
it ("should have the correct protocol",function(){
testDomain.protocol.should.equal("https");
})
}) })
describe(".Git class",function(){ describe(".Git class",function(){
let testGit:smartstring.GitRepo; let testGit:smartstring.GitRepo;

View File

@ -9,6 +9,7 @@ export class Domain {
level4:string; level4:string;
level5:string; level5:string;
protocol:string; protocol:string;
zoneName:string;
//aliases //aliases
topLevel:string; topLevel:string;
domainName; domainName;
@ -21,6 +22,9 @@ export class Domain {
this.level3 = regexMatches[2]; this.level3 = regexMatches[2];
this.level4 = regexMatches[3]; this.level4 = regexMatches[3];
this.level5 = regexMatches[4]; this.level5 = regexMatches[4];
this.protocol = protocolRegex(domainStringArg)[1];
this.zoneName = this.level2 + "." + this.level1;
// aliases // aliases
this.topLevel = this.level1; this.topLevel = this.level1;
this.domainName = this.level2; this.domainName = this.level2;
@ -38,3 +42,10 @@ let domainRegex = function(stringArg:string){
}); });
return regexMatchesFiltered; return regexMatchesFiltered;
}; };
let protocolRegex = function(stringArg:string){
let regexString = /^([a-zA-Z0-9]*):\/\//;
let regexMatches = regexString.exec(stringArg);
console.log(regexMatches);
return regexMatches;
}