This commit is contained in:
LosslessBot 2016-07-06 10:06:10 +02:00
commit d357d6e52d
6 changed files with 74 additions and 27 deletions

View File

@ -1,9 +1,16 @@
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-node:npmts
stages: stages:
- test - test
- release - release
testLEGACY:
stage: test
script:
- npmci test legacy
tags:
- docker
testLTS: testLTS:
stage: test stage: test
script: script:

View File

@ -1,14 +1,26 @@
"use strict"; "use strict";
var Domain = (function () { var Domain = (function () {
function Domain(domainStringArg) { function Domain(domainStringArg) {
this.fullName = domainStringArg;
var regexMatches = domainRegex(domainStringArg); var regexMatches = domainRegex(domainStringArg);
this.level1 = regexMatches[0]; this.fullName = "";
this.level2 = regexMatches[1]; for (var i = 1; i <= 5; i++) {
this.level3 = regexMatches[2]; if (regexMatches[i - 1]) {
this.level4 = regexMatches[3]; var localMatch = regexMatches[i - 1];
this.level5 = regexMatches[4]; this["level" + i.toString()] = localMatch;
this.protocol = protocolRegex(domainStringArg)[1]; if (this.fullName == "") {
this.fullName = localMatch;
}
else {
this.fullName = localMatch + "." + this.fullName;
}
}
else {
this["level" + i.toString()] = undefined;
}
;
}
;
this.protocol = protocolRegex(domainStringArg);
this.zoneName = this.level2 + "." + this.level1; this.zoneName = this.level2 + "." + this.level1;
// aliases // aliases
this.topLevel = this.level1; this.topLevel = this.level1;
@ -19,9 +31,10 @@ var Domain = (function () {
}()); }());
exports.Domain = Domain; exports.Domain = Domain;
var domainRegex = function (stringArg) { 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 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); var regexMatches = regexString.exec(stringArg);
regexMatches.reverse(); regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order)
regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements
var regexMatchesFiltered = regexMatches.filter(function (stringArg) { var regexMatchesFiltered = regexMatches.filter(function (stringArg) {
return (stringArg != ""); return (stringArg != "");
}); });
@ -30,7 +43,11 @@ var domainRegex = function (stringArg) {
var protocolRegex = function (stringArg) { var protocolRegex = function (stringArg) {
var regexString = /^([a-zA-Z0-9]*):\/\//; var regexString = /^([a-zA-Z0-9]*):\/\//;
var regexMatches = regexString.exec(stringArg); var regexMatches = regexString.exec(stringArg);
console.log(regexMatches); if (regexMatches) {
return regexMatches; return regexMatches[1];
}
else {
return undefined;
}
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuZG9tYWluLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuZG9tYWluLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTtJQWFJLGdCQUFZLGVBQXNCO1FBQzlCLElBQUksQ0FBQyxRQUFRLEdBQUcsZUFBZSxDQUFDO1FBQ2hDLElBQUksWUFBWSxHQUFHLFdBQVcsQ0FBQyxlQUFlLENBQUMsQ0FBQztRQUNoRCxJQUFJLENBQUMsTUFBTSxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM5QixJQUFJLENBQUMsTUFBTSxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM5QixJQUFJLENBQUMsTUFBTSxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM5QixJQUFJLENBQUMsTUFBTSxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM5QixJQUFJLENBQUMsTUFBTSxHQUFHLFl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BQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDO0lBQy9DLE9BQU8sQ0FBQyxHQUFHLENBQUMsWUFBWSxDQUFDLENBQUM7SUFDMUIsTUFBTSxDQUFDLFlBQVksQ0FBQztBQUN4QixDQUFDLENBQUEifQ==

View File

@ -1,6 +1,6 @@
{ {
"name": "smartstring", "name": "smartstring",
"version": "2.0.6", "version": "2.0.10",
"description": "handle strings in smart ways. TypeScript ready.", "description": "handle strings in smart ways. TypeScript ready.",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",

View File

@ -5,9 +5,11 @@ var should = require("should");
describe("smartstring", function () { describe("smartstring", function () {
describe(".Domain class", function () { describe(".Domain class", function () {
var testDomain; var testDomain;
var testDomain2;
it("should create a new Domain object", function () { it("should create a new Domain object", function () {
testDomain = new smartstring.Domain("https://level3D.level2D.level1D"); testDomain = new smartstring.Domain("https://level3D.level2D.level1D");
testDomain.should.be.instanceof(smartstring.Domain); testDomain.should.be.instanceof(smartstring.Domain);
console.log(testDomain);
}); });
it("should have a .topLevel", function () { it("should have a .topLevel", function () {
testDomain.topLevel.should.equal("level1D"); testDomain.topLevel.should.equal("level1D");
@ -24,6 +26,10 @@ describe("smartstring", function () {
it("should have the correct protocol", function () { it("should have the correct protocol", function () {
testDomain.protocol.should.equal("https"); testDomain.protocol.should.equal("https");
}); });
it("testDomain2 should be a basic domain", function () {
testDomain2 = new smartstring.Domain("bleu.de");
console.log(testDomain2);
});
}); });
describe(".Git class", function () { describe(".Git class", function () {
var testGit; var testGit;
@ -75,4 +81,3 @@ describe("smartstring", function () {
}); });
}); });
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FDUCxDQUFDLENBRG9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QUFDLDJCQUEyQixDQUFDO3FCQUN0RSxNQUFNLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRSxDQUFDO2dCQUN0QixXQUFXLENBQUMsVUFBVSxDQUFDLGtCQUFrQixDQUFDLElBQUksQ0FBQyw0QkFBNEIsQ0FBQztxQkFDdkUsTUFBTSxDQUFDLEVBQUUsQ0FBQyxLQUFLLEVBQUUsQ0FBQztZQUMzQixDQUFDLENBQUMsQ0FBQTtRQUNOLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQyJ9

View File

@ -5,9 +5,11 @@ let should = require("should");
describe("smartstring",function(){ describe("smartstring",function(){
describe(".Domain class",function(){ describe(".Domain class",function(){
let testDomain:smartstring.Domain; let testDomain:smartstring.Domain;
let testDomain2:smartstring.Domain;
it("should create a new Domain object",function(){ it("should create a new Domain object",function(){
testDomain = new smartstring.Domain("https://level3D.level2D.level1D"); testDomain = new smartstring.Domain("https://level3D.level2D.level1D");
testDomain.should.be.instanceof(smartstring.Domain); testDomain.should.be.instanceof(smartstring.Domain);
console.log(testDomain);
}); });
it("should have a .topLevel",function(){ it("should have a .topLevel",function(){
testDomain.topLevel.should.equal("level1D"); testDomain.topLevel.should.equal("level1D");
@ -24,6 +26,10 @@ describe("smartstring",function(){
it ("should have the correct protocol",function(){ it ("should have the correct protocol",function(){
testDomain.protocol.should.equal("https"); testDomain.protocol.should.equal("https");
}) })
it("testDomain2 should be a basic domain",function(){
testDomain2 = new smartstring.Domain("bleu.de");
console.log(testDomain2);
});
}) })
describe(".Git class",function(){ describe(".Git class",function(){
let testGit:smartstring.GitRepo; let testGit:smartstring.GitRepo;
@ -56,7 +62,7 @@ describe("smartstring",function(){
describe(".makeEnvObject",function(){ describe(".makeEnvObject",function(){
it("should create a Env Object",function(){ it("should create a Env Object",function(){
let envStringArray = ["VIRTUAL_HOST=sub.domain.tld","DEFAULT_HOST=some.domain.com"]; let envStringArray = ["VIRTUAL_HOST=sub.domain.tld","DEFAULT_HOST=some.domain.com"];
let envObject = smartstring.docker.makeEnvObject(envStringArray); let envObject:any = smartstring.docker.makeEnvObject(envStringArray);
envObject.VIRTUAL_HOST.should.equal("sub.domain.tld"); envObject.VIRTUAL_HOST.should.equal("sub.domain.tld");
envObject.DEFAULT_HOST.should.equal("some.domain.com"); envObject.DEFAULT_HOST.should.equal("some.domain.com");
}) })

View File

@ -14,14 +14,22 @@ export class Domain {
domainName; domainName;
subDomain; subDomain;
constructor(domainStringArg:string){ constructor(domainStringArg:string){
this.fullName = domainStringArg;
let regexMatches = domainRegex(domainStringArg); let regexMatches = domainRegex(domainStringArg);
this.level1 = regexMatches[0]; this.fullName = "";
this.level2 = regexMatches[1]; for(let i = 1; i <= 5; i++){
this.level3 = regexMatches[2]; if(regexMatches[i - 1]) {
this.level4 = regexMatches[3]; let localMatch = regexMatches[i - 1]
this.level5 = regexMatches[4]; this["level" + i.toString()] = localMatch;
this.protocol = protocolRegex(domainStringArg)[1]; if (this.fullName == ""){
this.fullName = localMatch;
} else {
this.fullName = localMatch + "." + this.fullName;
}
} else {
this["level" + i.toString()] = undefined;
};
};
this.protocol = protocolRegex(domainStringArg);
this.zoneName = this.level2 + "." + this.level1; this.zoneName = this.level2 + "." + this.level1;
// aliases // aliases
@ -33,9 +41,10 @@ export class Domain {
let domainRegex = function(stringArg:string){ let domainRegex = function(stringArg:string){
let 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}$/; let 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}$/;
let regexMatches = regexString.exec(stringArg); let regexMatches = regexString.exec(stringArg);
regexMatches.reverse(); regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order)
regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements
let regexMatchesFiltered = regexMatches.filter(function(stringArg:string){ let regexMatchesFiltered = regexMatches.filter(function(stringArg:string){
return(stringArg != ""); return(stringArg != "");
}); });
@ -45,6 +54,9 @@ let domainRegex = function(stringArg:string){
let protocolRegex = function(stringArg:string){ let protocolRegex = function(stringArg:string){
let regexString = /^([a-zA-Z0-9]*):\/\//; let regexString = /^([a-zA-Z0-9]*):\/\//;
let regexMatches = regexString.exec(stringArg); let regexMatches = regexString.exec(stringArg);
console.log(regexMatches); if(regexMatches){
return regexMatches; return regexMatches[1];
} else {
return undefined;
}
} }