Various bug fixes for URI format parsing

This commit is contained in:
Peng-YM
2022-06-20 17:00:57 +08:00
parent 4dde556daf
commit e401a31b6c
7 changed files with 68 additions and 74 deletions

View File

@@ -13,4 +13,20 @@ function isIPv6(ip) {
return IPV6_REGEX.test(ip);
}
export { isIPv4, isIPv6 };
function isNotBlank(str) {
return typeof str === 'string' && str.trim().length > 0;
}
function getIfNotBlank(str, defaultValue) {
return isNotBlank(str) ? str : defaultValue;
}
function isPresent(obj) {
return typeof obj !== 'undefined' && obj !== null;
}
function getIfPresent(obj, defaultValue) {
return isPresent(obj) ? obj : defaultValue;
}
export { isIPv4, isIPv6, isNotBlank, getIfNotBlank, isPresent, getIfPresent };