@@ -57,43 +57,6 @@ const getButtonTitle = (formId: string) => {
5757 }
5858} ;
5959
60- // Detects spam-like patterns in text (random mixed-case strings)
61- const isLikelySpam = ( text : string ) : boolean => {
62- if ( ! text ) return false ;
63-
64- const letters = text . replace ( / [ ^ a - z A - Z ] / g, '' ) ;
65- if ( letters . length === 0 ) return false ;
66-
67- // Allow all uppercase (like "IBM", "NASA", "JOHN SMITH")
68- if ( letters === letters . toUpperCase ( ) ) return false ;
69-
70- // Allow all lowercase (like "john smith")
71- if ( letters === letters . toLowerCase ( ) ) return false ;
72-
73- // Count ANY case transitions (uppercase to lowercase OR lowercase to uppercase)
74- const lowToHigh = ( text . match ( / [ a - z ] [ A - Z ] / g) || [ ] ) . length ;
75- const highToLow = ( text . match ( / [ A - Z ] [ a - z ] / g) || [ ] ) . length ;
76- const totalTransitions = lowToHigh + highToLow ;
77-
78- // Count uppercase letters
79- const uppercaseCount = ( letters . match ( / [ A - Z ] / g) || [ ] ) . length ;
80- const uppercaseRatio = uppercaseCount / letters . length ;
81-
82- // Spam pattern 1: 4+ total case transitions
83- // Examples: CuxFbsjOMshzd (6), lxBMWgpkbCX (4), wUwqIVjOmhQbJi (10)
84- // Legitimate: Christopher (2), McDonald (2), iPhone (2), MacBook (2)
85- if ( totalTransitions >= 4 ) return true ;
86-
87- // Spam pattern 2: Uppercase ratio in suspicious range (30-95%)
88- // Too random to be legitimate mixed case (which is typically <30%)
89- // Not all caps (which would be 100%)
90- // Examples: lxBMWgpkbCX (42%), cVBaaQcPphWeXH (64%), CuxFbsjOMshzd (38%)
91- // Legitimate: McDonald (25%), iPhone (33% but only 2 transitions), John (25%)
92- if ( uppercaseRatio > 0.3 && uppercaseRatio < 0.95 ) return true ;
93-
94- return false ;
95- } ;
96-
9760// Retry a fetch request up to 3 times with exponential backoff
9861const fetchWithRetry = async ( url : string , options : RequestInit ) : Promise < Response > => {
9962 const maxRetries = 3 ;
@@ -121,52 +84,6 @@ const fetchWithRetry = async (url: string, options: RequestInit): Promise<Respon
12184 throw lastError || new Error ( 'Request failed' ) ;
12285} ;
12386
124- const detectSpamSubmission = ( values : ValueType ) : boolean => {
125- const { firstname, lastname, company, email, message } = values ;
126-
127- let spamScore = 0 ;
128-
129- // High confidence spam indicators (3 points each)
130- if ( isLikelySpam ( firstname ) ) spamScore += 3 ;
131- if ( isLikelySpam ( lastname ) ) spamScore += 3 ;
132- if ( isLikelySpam ( company ) ) spamScore += 3 ;
133- if ( company . trim ( ) . length <= 2 ) spamScore += 3 ;
134-
135- // Medium confidence indicators (2 points each)
136- const freeEmailDomains = [
137- 'gmail.com' ,
138- 'yahoo.com' ,
139- 'hotmail.com' ,
140- 'outlook.com' ,
141- 'aol.com' ,
142- 'icloud.com' ,
143- 't-online.de' ,
144- ] ;
145- const emailDomain = email . toLowerCase ( ) . split ( '@' ) [ 1 ] || '' ;
146- if ( ! emailDomain ) {
147- // Invalid email format (missing domain) - likely spam
148- spamScore += 2 ;
149- } else if ( freeEmailDomains . includes ( emailDomain ) ) {
150- spamScore += 2 ;
151- }
152-
153- // Low confidence indicators (1 point each)
154- const messageWords = ( message || '' )
155- . trim ( )
156- . split ( / \s + / )
157- . filter ( ( word ) => word . length > 0 ) ;
158- if ( messageWords . length < 5 ) spamScore += 1 ;
159-
160- // Flag as spam if score >= 5
161- // Examples:
162- // - Random case name (3) + free email (2) = spam
163- // - Random case name (3) + short company (3) = spam
164- // - Free email (2) + short message (1) + short company (3) = spam
165- // - Free email (2) + short company (3) = not spam (legitimate small companies)
166- // - Free email (2) + short message (1) = not spam
167- return spamScore >= 5 ;
168- } ;
169-
17087const ContactForm = ( {
17188 className,
17289 formId,
@@ -205,9 +122,6 @@ const ContactForm = ({
205122 setButtonState ( STATES . LOADING ) ;
206123 setFormError ( '' ) ;
207124
208- const isSpam = detectSpamSubmission ( values ) ;
209- const spamPrefix = isSpam ? '🙄 ' : '' ;
210-
211125 try {
212126 if (
213127 formId == VIEW_LIVE_DEMO ||
@@ -241,7 +155,6 @@ const ContactForm = ({
241155 email,
242156 company,
243157 message,
244- isSpam,
245158 } ) ,
246159 } ) ;
247160
@@ -256,7 +169,7 @@ const ContactForm = ({
256169 body : JSON . stringify ( {
257170 msg_type : 'text' ,
258171 content : {
259- text : `${ spamPrefix } ${ formId } by ${ firstname } ${ lastname } (${ email } ) from ${ company } \n\n${ message } ` ,
172+ text : `${ formId } by ${ firstname } ${ lastname } (${ email } ) from ${ company } \n\n${ message } ` ,
260173 } ,
261174 } ) ,
262175 } ) . catch ( ( ) => {
0 commit comments