@indodev/toolkit 0.4.2 → 0.5.0

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.
package/dist/index.cjs CHANGED
@@ -754,24 +754,12 @@ function normalizePhoneNumber(phone) {
754
754
  }
755
755
  return "";
756
756
  }
757
- function normalizeToNational(phone) {
758
- if (phone.startsWith("+62")) {
759
- return "0" + phone.substring(3);
760
- }
761
- if (phone.startsWith("62") && !phone.startsWith("620")) {
762
- return "0" + phone.substring(2);
763
- }
764
- if (phone.startsWith("0")) {
765
- return phone;
766
- }
767
- return "";
768
- }
769
757
  function getLandlineRegion(phone) {
770
758
  if (!phone || typeof phone !== "string") {
771
759
  return null;
772
760
  }
773
761
  const cleaned = phone.replace(/[^\d+]/g, "");
774
- const normalized = normalizeToNational(cleaned);
762
+ const normalized = normalizePhoneNumber(cleaned);
775
763
  if (!normalized || !normalized.startsWith("0")) {
776
764
  return null;
777
765
  }
@@ -942,7 +930,7 @@ function maskPhoneNumber(phone, options = {}) {
942
930
 
943
931
  // src/phone/links.ts
944
932
  function generateWALink(phone, message) {
945
- if (!validatePhoneNumber(phone)) {
933
+ if (!validatePhoneNumber(phone) || !isMobileNumber(phone)) {
946
934
  return "";
947
935
  }
948
936
  const e164 = toE164(phone);
@@ -953,7 +941,7 @@ function generateWALink(phone, message) {
953
941
  return link;
954
942
  }
955
943
  function generateSmsLink(phone, body) {
956
- if (!validatePhoneNumber(phone)) {
944
+ if (!validatePhoneNumber(phone) || !isMobileNumber(phone)) {
957
945
  return "";
958
946
  }
959
947
  const e164 = toE164(phone);