2016-05-25 03:06:19 +00:00
|
|
|
"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];
|
2016-05-25 04:54:55 +00:00
|
|
|
this.protocol = protocolRegex(domainStringArg)[1];
|
|
|
|
this.zoneName = this.level2 + "." + this.level1;
|
2016-05-25 03:06:19 +00:00
|
|
|
// 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;
|
|
|
|
};
|
2016-05-25 04:54:55 +00:00
|
|
|
var protocolRegex = function (stringArg) {
|
|
|
|
var regexString = /^([a-zA-Z0-9]*):\/\//;
|
|
|
|
var regexMatches = regexString.exec(stringArg);
|
|
|
|
console.log(regexMatches);
|
|
|
|
return regexMatches;
|
|
|
|
};
|
2016-05-25 03:06:19 +00:00
|
|
|
|
2016-06-05 07:31:10 +00:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3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