39 lines
5.4 KiB
JavaScript
39 lines
5.4 KiB
JavaScript
"use strict";
|
|
require("typings-global");
|
|
var Domain = (function () {
|
|
function Domain(domainStringArg) {
|
|
this.fullName = domainStringArg;
|
|
var regexMatches = domainRegex(domainStringArg);
|
|
this.level1 = regexMatches[0];
|
|
this.level2 = regexMatches[1];
|
|
this.level3 = regexMatches[2];
|
|
this.level4 = regexMatches[3];
|
|
this.level5 = regexMatches[4];
|
|
this.protocol = protocolRegex(domainStringArg)[1];
|
|
this.zoneName = this.level2 + "." + this.level1;
|
|
// aliases
|
|
this.topLevel = this.level1;
|
|
this.domainName = this.level2;
|
|
this.subDomain = this.level3;
|
|
}
|
|
return Domain;
|
|
}());
|
|
exports.Domain = Domain;
|
|
var domainRegex = function (stringArg) {
|
|
var regexString = /([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}$/;
|
|
var regexMatches = regexString.exec(stringArg);
|
|
regexMatches.reverse();
|
|
var regexMatchesFiltered = regexMatches.filter(function (stringArg) {
|
|
return (stringArg != "");
|
|
});
|
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLmRvbWFpbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFDUCxDQUFDLENBRHNCO0FBR3ZCO0lBYUksZ0JBQVksZUFBc0I7UUFDOUIsSUFBSSxDQUFDLFFBQVEsR0FBRyxlQUFlLENBQUM7UUFDaEMsSUFBSSxZQUFZLEdBQUcsV0FBVyxDQU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