Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
4bcf9f941e | |||
afb204325b | |||
cefbb6eecd | |||
c6a1a45812 | |||
00a892ee82 | |||
0eb6d13be9 | |||
c34f9611f9 | |||
820360a220 |
@ -1,9 +1,16 @@
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
|
41
dist/smartstring.domain.js
vendored
41
dist/smartstring.domain.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "smartstring",
|
||||
"version": "2.0.6",
|
||||
"version": "2.0.10",
|
||||
"description": "handle strings in smart ways. TypeScript ready.",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
@ -22,12 +22,12 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
|
||||
"devDependencies": {
|
||||
"npmts": "^5.2.1",
|
||||
"should": "^9.0.0",
|
||||
"npmts-g": "^5.2.6",
|
||||
"should": "^9.0.2",
|
||||
"typings-test": "^1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"beautylog": "^5.0.8",
|
||||
"beautylog": "^5.0.12",
|
||||
"typings-global": "^1.0.3"
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -5,9 +5,11 @@ let should = require("should");
|
||||
describe("smartstring",function(){
|
||||
describe(".Domain class",function(){
|
||||
let testDomain:smartstring.Domain;
|
||||
let testDomain2:smartstring.Domain;
|
||||
it("should create a new Domain object",function(){
|
||||
testDomain = new smartstring.Domain("https://level3D.level2D.level1D");
|
||||
testDomain.should.be.instanceof(smartstring.Domain);
|
||||
console.log(testDomain);
|
||||
});
|
||||
it("should have a .topLevel",function(){
|
||||
testDomain.topLevel.should.equal("level1D");
|
||||
@ -24,6 +26,10 @@ describe("smartstring",function(){
|
||||
it ("should have the correct protocol",function(){
|
||||
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(){
|
||||
let testGit:smartstring.GitRepo;
|
||||
@ -56,7 +62,7 @@ describe("smartstring",function(){
|
||||
describe(".makeEnvObject",function(){
|
||||
it("should create a Env Object",function(){
|
||||
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.DEFAULT_HOST.should.equal("some.domain.com");
|
||||
})
|
||||
|
@ -15,14 +15,22 @@ export class Domain {
|
||||
domainName;
|
||||
subDomain;
|
||||
constructor(domainStringArg:string){
|
||||
this.fullName = domainStringArg;
|
||||
let 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.fullName = "";
|
||||
for(let i = 1; i <= 5; i++){
|
||||
if(regexMatches[i - 1]) {
|
||||
let localMatch = regexMatches[i - 1]
|
||||
this["level" + i.toString()] = localMatch;
|
||||
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;
|
||||
|
||||
// aliases
|
||||
@ -34,9 +42,10 @@ export class Domain {
|
||||
|
||||
|
||||
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);
|
||||
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){
|
||||
return(stringArg != "");
|
||||
});
|
||||
@ -46,6 +55,9 @@ let domainRegex = function(stringArg:string){
|
||||
let protocolRegex = function(stringArg:string){
|
||||
let regexString = /^([a-zA-Z0-9]*):\/\//;
|
||||
let regexMatches = regexString.exec(stringArg);
|
||||
console.log(regexMatches);
|
||||
return regexMatches;
|
||||
if(regexMatches){
|
||||
return regexMatches[1];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user