@@ -124,14 +124,14 @@ async function handleRequest(request) {
124124 if ( response . status != 200 ) {
125125 return new Response ( "Error while signing up for " + listsToSubscribeTo [ i ] , { status :response . status , headers :corsHeaders } )
126126 }
127-
128- // If we get here, we managed to sign up for the lists
129- const sendmailresponse = await sendConfirmationEmail ( bodydata . address , bodydata . name , listsToSubscribeTo )
130- if ( sendmailresponse . status != 200 ) {
131- return new Response ( "You were signed up, but sending a confirmation email failed." , { status :sendmailresponse . status , headers :corsHeaders } )
132- }
133- return new Response ( "Succesfully subscribed. You will receive a confirmation email." , { status :200 , headers :corsHeaders } )
134127 }
128+
129+ // If we get here, we managed to sign up for the lists
130+ const sendmailresponse = await sendConfirmationEmail ( bodydata . address , bodydata . name , listsToSubscribeTo )
131+ if ( sendmailresponse . status != 200 ) {
132+ return new Response ( "You were signed up, but sending a confirmation email failed." , { status :sendmailresponse . status , headers :corsHeaders } )
133+ }
134+ return new Response ( "Succesfully subscribed. You will receive a confirmation email." , { status :200 , headers :corsHeaders } )
135135 }
136136 }
137137 catch ( err )
@@ -160,10 +160,11 @@ async function sendConfirmationEmail(address, name, lists) {
160160
161161 if ( i == lists . length - 2 ) {
162162 thankYouMsg += " and "
163- } else if ( i != 0 ) {
163+ } else if ( i != 0 && i != lists . length - 1 ) {
164164 thankYouMsg += ", "
165165 }
166166 }
167+ thankYouMsg += "." ;
167168
168169 var mailBody = welcomeEmail . replace ( "NAME" , name )
169170 var mailBody = mailBody . replace ( "THANKYOUMSG" , thankYouMsg )
0 commit comments