now correctly parsing a Domain

This commit is contained in:
2016-05-25 05:06:19 +02:00
parent 6a1fb1ec50
commit bd4de36143
22 changed files with 176 additions and 62 deletions

View File

@ -1,8 +1,8 @@
/// <reference path="./typings/main.d.ts" />
import SmartstringGit = require("./smartstring.git");
import "typings-global"
import SmartstringDocker = require("./smartstring.docker");
import SmartstringTypescript = require("./smartstring.typescript");
export let git = SmartstringGit.git;
export {Domain} from "./smartstring.domain";
export {GitRepo} from "./smartstring.git";
export let docker = SmartstringDocker;
export let typescript = SmartstringTypescript;

View File

@ -1,4 +1,4 @@
/// <reference path="./typings/main.d.ts" />
import "typings-global"
import plugins = require("./smartstring.plugins");
/**

40
ts/smartstring.domain.ts Normal file
View File

@ -0,0 +1,40 @@
import "typings-global"
import plugins = require("./smartstring.plugins");
export class Domain {
fullName:string;
level1:string;
level2:string;
level3:string;
level4:string;
level5:string;
protocol:string;
//aliases
topLevel:string;
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];
// aliases
this.topLevel = this.level1;
this.domainName = this.level2;
this.subDomain = this.level3;
}
}
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 regexMatches = regexString.exec(stringArg);
regexMatches.reverse();
let regexMatchesFiltered = regexMatches.filter(function(stringArg:string){
return(stringArg != "");
});
return regexMatchesFiltered;
};

View File

@ -1,10 +1,10 @@
/// <reference path="./typings/main.d.ts" />
import "typings-global"
import plugins = require("./smartstring.plugins");
/* ---------------------------------------------- *
* ------------------ classes ------------------- *
* ---------------------------------------------- */
export class gitRepo {
export class GitRepo {
host:string;
user:string;
repo:string;
@ -50,12 +50,4 @@ let gitLink = function(hostArg:string, userArg:string, repoArg:string, tokenArg:
break;
}
return returnString;
};
/* ---------------------------------------------- *
* ------------------ exports ------------------- *
* ---------------------------------------------- */
export let git = function(stringArg:string,tokenArg?:string){
let localGitRepo = new gitRepo(stringArg,tokenArg);
return localGitRepo;
};

View File

@ -1,3 +1,3 @@
/// <reference path="./typings/main.d.ts" />
import "typings-global"
export import beautylog = require("beautylog");

View File

@ -1,3 +1,4 @@
import "typings-global"
import plugins = require("./smartstring.plugins");
export let regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/