- renamed 'models' and 'validators' folders - removed unneccessary files in contracts folder
This commit is contained in:
parent
a29865b781
commit
08c2edca3b
62 changed files with 371 additions and 458 deletions
26
app/utils/utility-functions.ts
Normal file
26
app/utils/utility-functions.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
export function sum(a: number, b: number): number {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
export function getDomain(host: string): string {
|
||||
// $myhost = strtolower(trim($host));
|
||||
let myHost: string = host.trim().toLocaleLowerCase();
|
||||
// $count = substr_count($myhost, '.');
|
||||
const count: number = myHost.split(',').length - 1;
|
||||
|
||||
if (count == 2) {
|
||||
const words = myHost.split('.');
|
||||
if (words[1].length > 3) {
|
||||
myHost = myHost.split('.', 2)[1];
|
||||
}
|
||||
} else if (count > 2) {
|
||||
myHost = getDomain(myHost.split('.', 2)[1]);
|
||||
}
|
||||
myHost = myHost.replace(new RegExp(/^.*:\/\//i, 'g'), '');
|
||||
return myHost;
|
||||
}
|
||||
|
||||
export function preg_match(regex: RegExp, str: string) {
|
||||
const result: boolean = regex.test(str);
|
||||
return result;
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue