@@ -20,6 +20,18 @@ async function loadEmailAccounts() {
2020 }
2121}
2222
23+ // Add this helper function near the top of the file
24+ function isValidDestination ( destination ) {
25+ // Allow special destinations
26+ if ( destination . startsWith ( ':' ) || destination . startsWith ( '|' ) ) {
27+ return true ;
28+ }
29+
30+ // Otherwise check if it's a valid email
31+ const emailRegex = / ^ [ ^ \s @ ] + @ [ ^ \s @ ] + \. [ ^ \s @ ] + $ / ;
32+ return emailRegex . test ( destination ) ;
33+ }
34+
2335// Update destination dropdown with email accounts
2436function updateDestinationDropdown ( ) {
2537 const select = document . getElementById ( 'destination' ) ;
@@ -60,7 +72,7 @@ function updateDestinationDropdown() {
6072
6173 // Handle selection changes
6274 select . addEventListener ( 'change' , function ( ) {
63- const customInput = document . getElementById ( 'customDestination ' ) ;
75+ const customInput = document . getElementById ( 'custom-destination ' ) ;
6476 if ( this . value === 'custom' ) {
6577 customInput . style . display = 'block' ;
6678 customInput . required = true ;
@@ -147,23 +159,24 @@ async function createForwarder(event) {
147159 const form = event . target ;
148160 const addressInput = form . querySelector ( '#address' ) ;
149161 const destinationSelect = form . querySelector ( '#destination' ) ;
150- const customDestInput = form . querySelector ( '#customDestination ' ) ;
162+ const customDestInput = form . querySelector ( '#custom-estination ' ) ;
151163 const submitButton = form . querySelector ( 'button[type="submit"]' ) ;
152164
153165 // Get the actual destination
154166 let destination = destinationSelect . value ;
155167 if ( destination === 'custom' ) {
156168 destination = customDestInput . value . trim ( ) ;
157169 if ( ! destination ) {
158- showMessage ( 'Please enter a custom email address ' , 'error' ) ;
170+ showMessage ( 'Please enter a custom destination ' , 'error' ) ;
159171 customDestInput . focus ( ) ;
160172 return ;
161173 }
162174 }
163175
164176 // Validate
165- if ( ! addressInput . value . trim ( ) || ! destination ) {
166- showMessage ( 'Please fill in all required fields' , 'error' ) ;
177+ if ( ! isValidDestination ( destination ) ) {
178+ showMessage ( 'Please enter a valid email address or special destination (e.g., :blackhole:, :fail:)' , 'error' ) ;
179+ customDestInput . focus ( ) ;
167180 return ;
168181 }
169182
0 commit comments