Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
4bcf9f941e | |||
afb204325b | |||
cefbb6eecd | |||
c6a1a45812 | |||
00a892ee82 | |||
0eb6d13be9 |
@ -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:
|
||||
|
15
dist/smartstring.domain.js
vendored
15
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.7",
|
||||
"version": "2.0.10",
|
||||
"description": "handle strings in smart ways. TypeScript ready.",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user