Skip to content

Commit 2abc85c

Browse files
aliyzlclaude
andcommitted
fix: prevent Enter key from submitting form to non-existent /search route
Pressing Enter in the URL input submitted the form via GET to /search, which has no route and returned a 404 ("NotFoundError: Not Found"). The download was only wired to the button's click handler. Intercept the form's submit event, prevent the default navigation, and trigger the same socket-based download. Enter now works like clicking the download button. Logic extracted into a shared startDownload() function. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent be3e857 commit 2abc85c

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

views/layout.hbs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,23 @@
6464
}
6565
})
6666
67-
// Download a website on click
68-
const downloadBtn = document.getElementById("download");
69-
downloadBtn.onclick=()=>{
67+
// Download a website on click (or when pressing Enter in the form)
68+
function startDownload(){
7069
var website = document.getElementById('website').value
70+
if(!website) return;
7171
console.log("Now downloading the website ... %s",website)
7272
socket.emit('request', { token: localStorage['token'] , website});
7373
}
74+
const downloadBtn = document.getElementById("download");
75+
downloadBtn.onclick = startDownload;
76+
// Prevent the form's default GET /search submission (which 404s) and download instead
77+
const downloadForm = document.querySelector('form.form');
78+
if(downloadForm){
79+
downloadForm.addEventListener('submit', function(e){
80+
e.preventDefault();
81+
startDownload();
82+
});
83+
}
7484
7585
7686

0 commit comments

Comments
 (0)