namirasoft-core
Advanced tools
Comparing version 1.4.23 to 1.4.24
export declare class BaseUUID { | ||
private static SIZE; | ||
static isValid(id: any): boolean; | ||
static getShort(id: string): string; | ||
@@ -4,0 +5,0 @@ short: string; |
@@ -6,4 +6,22 @@ "use strict"; | ||
class BaseUUID { | ||
static isValid(id) { | ||
let value = id + ""; | ||
if (value.length != BaseUUID.SIZE) | ||
return false; | ||
let parts = id.split("@")[0].split("-"); | ||
if (parts.length < 2) | ||
return false; | ||
return /^[a-z][a-z][a-z]$/.test(parts[0]); | ||
} | ||
static getShort(id) { | ||
return id.split("-")[0]; | ||
let parts = id.split("@")[0].split("-"); | ||
let ans = []; | ||
for (let index = 0; index < parts.length - 1; index++) { | ||
const part = parts[index]; | ||
if (/^[a-z][a-z][a-z]$/.test(part)) | ||
ans.push(part); | ||
else | ||
break; | ||
} | ||
return ans.join("-"); | ||
} | ||
@@ -10,0 +28,0 @@ constructor(short) { |
@@ -11,3 +11,3 @@ { | ||
"private": false, | ||
"version": "1.4.23", | ||
"version": "1.4.24", | ||
"author": "Amir Abolhasani", | ||
@@ -14,0 +14,0 @@ "license": "MIT", |
@@ -6,5 +6,25 @@ import { v4 } from "uuid"; | ||
private static SIZE = 20; | ||
static isValid(id: any) | ||
{ | ||
let value = id + ""; | ||
if (value.length != BaseUUID.SIZE) | ||
return false; | ||
let parts = id.split("@")[0].split("-"); | ||
if (parts.length < 2) | ||
return false; | ||
return /^[a-z][a-z][a-z]$/.test(parts[0]); | ||
} | ||
static getShort(id: string) | ||
{ | ||
return id.split("-")[0]; | ||
let parts = id.split("@")[0].split("-"); | ||
let ans = []; | ||
for (let index = 0; index < parts.length - 1; index++) | ||
{ | ||
const part = parts[index]; | ||
if (/^[a-z][a-z][a-z]$/.test(part)) | ||
ans.push(part); | ||
else | ||
break; | ||
} | ||
return ans.join("-"); | ||
} | ||
@@ -11,0 +31,0 @@ short: string; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
424505
5641