@yomologic/react-ui 0.6.3 → 0.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.
package/dist/index.d.mts CHANGED
@@ -1150,8 +1150,9 @@ declare function cn(...inputs: ClassValue[]): string;
1150
1150
  * Validation constants and regex patterns
1151
1151
  */
1152
1152
  /**
1153
- * RFC 5322 compliant email validation regex (simplified)
1153
+ * Email validation regex
1154
1154
  * Matches standard email formats like: user@example.com
1155
+ * Requires @ symbol, domain name, and TLD (like .com, .org, etc.)
1155
1156
  */
1156
1157
  declare const EMAIL_REGEX: RegExp;
1157
1158
  /**
@@ -1169,7 +1170,8 @@ declare const PHONE_REGEX: RegExp;
1169
1170
  */
1170
1171
  declare const isValidEmail: (email: string) => boolean;
1171
1172
  /**
1172
- * Validate URL format
1173
+ * Validate URL format and security
1174
+ * Checks for valid http/https protocol and blocks dangerous protocols
1173
1175
  */
1174
1176
  declare const isValidUrl: (url: string) => boolean;
1175
1177
  /**
package/dist/index.d.ts CHANGED
@@ -1150,8 +1150,9 @@ declare function cn(...inputs: ClassValue[]): string;
1150
1150
  * Validation constants and regex patterns
1151
1151
  */
1152
1152
  /**
1153
- * RFC 5322 compliant email validation regex (simplified)
1153
+ * Email validation regex
1154
1154
  * Matches standard email formats like: user@example.com
1155
+ * Requires @ symbol, domain name, and TLD (like .com, .org, etc.)
1155
1156
  */
1156
1157
  declare const EMAIL_REGEX: RegExp;
1157
1158
  /**
@@ -1169,7 +1170,8 @@ declare const PHONE_REGEX: RegExp;
1169
1170
  */
1170
1171
  declare const isValidEmail: (email: string) => boolean;
1171
1172
  /**
1172
- * Validate URL format
1173
+ * Validate URL format and security
1174
+ * Checks for valid http/https protocol and blocks dangerous protocols
1173
1175
  */
1174
1176
  declare const isValidUrl: (url: string) => boolean;
1175
1177
  /**
package/dist/index.js CHANGED
@@ -47,13 +47,16 @@ var EMAIL_REGEX, URL_REGEX, PHONE_REGEX, isValidEmail, isValidUrl, DATE_REGEX, i
47
47
  var init_validation = __esm({
48
48
  "src/constants/validation.ts"() {
49
49
  "use strict";
50
- EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
50
+ EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;
51
51
  URL_REGEX = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/;
52
52
  PHONE_REGEX = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/;
53
53
  isValidEmail = (email) => {
54
54
  return EMAIL_REGEX.test(email);
55
55
  };
56
56
  isValidUrl = (url) => {
57
+ if (/^(javascript|data|vbscript|file|about):/i.test(url)) {
58
+ return false;
59
+ }
57
60
  return URL_REGEX.test(url);
58
61
  };
59
62
  DATE_REGEX = /^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/\d{4}$/;
@@ -987,6 +990,9 @@ function useFormField2(options) {
987
990
  return errorMessages?.email || "Please enter a valid email address";
988
991
  }
989
992
  if (type === "url") {
993
+ if (/^(javascript|data|vbscript|file|about):/i.test(value)) {
994
+ return errorMessages?.url || "Invalid URL protocol";
995
+ }
990
996
  try {
991
997
  new URL(value);
992
998
  } catch {
@@ -1044,6 +1050,11 @@ function useFormField2(options) {
1044
1050
  return errorMessages?.email || "Please enter a valid email address";
1045
1051
  }
1046
1052
  if (type === "url") {
1053
+ if (/^(javascript|data|vbscript|file|about):/i.test(
1054
+ value
1055
+ )) {
1056
+ return errorMessages?.url || "Invalid URL protocol";
1057
+ }
1047
1058
  try {
1048
1059
  new URL(value);
1049
1060
  } catch {