@stemy/ngx-utils 19.6.2 → 19.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2280,6 +2280,8 @@ class StringUtils {
2280
2280
  str => !!str).join(separator);
2281
2281
  }
2282
2282
  static startsWith(str, ...starts) {
2283
+ if (typeof str !== "string")
2284
+ return false;
2283
2285
  for (let i = 0; i < starts.length; i++) {
2284
2286
  if (str.startsWith(starts[i]))
2285
2287
  return true;
@@ -2287,6 +2289,8 @@ class StringUtils {
2287
2289
  return false;
2288
2290
  }
2289
2291
  static has(str, ...parts) {
2292
+ if (typeof str !== "string")
2293
+ return false;
2290
2294
  for (let i = 0; i < parts.length; i++) {
2291
2295
  if (str.indexOf(parts[i]) >= 0)
2292
2296
  return true;
@@ -2294,17 +2298,21 @@ class StringUtils {
2294
2298
  return false;
2295
2299
  }
2296
2300
  static lcFirst(str) {
2297
- return str ? str.charAt(0).toLowerCase() + str.substring(1) : "";
2301
+ return typeof str === "string" ? str.charAt(0).toLowerCase() + str.substring(1) : "";
2298
2302
  }
2299
2303
  static ucFirst(str) {
2300
- return str ? str.charAt(0).toUpperCase() + str.substring(1) : "";
2304
+ return typeof str === "string" ? str.charAt(0).toUpperCase() + str.substring(1) : "";
2305
+ }
2306
+ static camelize(str) {
2307
+ return StringUtils.ucFirst(str)
2308
+ .replace(/[-.]([a-z])/g, g => g[1].toUpperCase());
2301
2309
  }
2302
2310
  static isObjectId(id) {
2303
2311
  return typeof id === "string" && id.length == 24 && !isNaN(Number("0x" + id));
2304
2312
  }
2305
2313
  static parseDomain(baseUrl) {
2306
2314
  try {
2307
- const url = new URL(baseUrl);
2315
+ const url = new URL(String(baseUrl || ""));
2308
2316
  const port = url.port && url.port !== "443" && url.port !== "80" ? `:${url.port}` : ``;
2309
2317
  return `${url.protocol}//${url.hostname}${port}/`;
2310
2318
  }