Compare commits

...

4 Commits

Author SHA1 Message Date
4bcf9f941e 2.0.10 2016-06-22 12:55:32 +02:00
afb204325b fix Domain Regex to include - and _ 2016-06-22 12:55:29 +02:00
cefbb6eecd 2.0.9 2016-06-21 18:59:08 +02:00
c6a1a45812 fix Domain.fullName 2016-06-21 18:59:05 +02:00
3 changed files with 21 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

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

View File

@ -15,11 +15,17 @@ export class Domain {
domainName;
subDomain;
constructor(domainStringArg:string){
this.fullName = domainStringArg;
let regexMatches = domainRegex(domainStringArg);
this.fullName = "";
for(let i = 1; i <= 5; i++){
if(regexMatches[i - 1]) {
this["level" + i.toString()] = 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;
};
@ -36,7 +42,7 @@ 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(); //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