From 4f68ac7d5ca95b9fa6ced4d6d17363760aef7f1b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 May 2026 17:08:36 +0000 Subject: [PATCH 1/3] Initial plan From 697bbf142f0e1a03147afffbbeeaf1e26d44f864 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 May 2026 17:11:59 +0000 Subject: [PATCH 2/3] fix: robustly detect wget download folder before archiving Agent-Logs-Url: https://github.com/AhmadIbrahiim/Website-downloader/sessions/7f20200c-2cfd-4ac6-958e-6256c981457e Co-authored-by: AhmadIbrahiim <17949497+AhmadIbrahiim@users.noreply.github.com> --- wget/index.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/wget/index.js b/wget/index.js index 8ac35e4..afd1856 100644 --- a/wget/index.js +++ b/wget/index.js @@ -21,18 +21,28 @@ const child = exec(`wget -mkEpnp --no-if-modified-since ${data.website}`); // read stdout from the current child. child.stderr.on("data",(response)=>{ + const responseText = response.toString(); - if(response.startsWith("Resolving ")) + if(!website) { - website= response.substring(response.indexOf('Resolve ')+11,response.indexOf(' (')) + const resolvingMatch = responseText.match(/Resolving\s+([^\s(]+)/); + if (resolvingMatch && resolvingMatch[1]) { + website = resolvingMatch[1]; + } } - io.emit(data.token,{progress:response}) + io.emit(data.token,{progress:responseText}) }) child.stderr.on('close',(response)=>{ + const websiteFolder = website || getWebsiteFolderName(data.website); + + if (!websiteFolder) { + io.emit(data.token, { progress: "Unable to determine downloaded website folder." }); + return; + } io.emit(data.token,{progress:"Converting"}) - archiver(website,io,data) + archiver(websiteFolder,io,data) }) // Handle process termination and cleanup @@ -53,4 +63,14 @@ function removePartiallyDownloadedFiles(website) { } }); } + +function getWebsiteFolderName(websiteUrl) { + try { + const normalizedUrl = /^https?:\/\//i.test(websiteUrl) ? websiteUrl : `http://${websiteUrl}`; + const parsedUrl = new URL(normalizedUrl); + return parsedUrl.port ? `${parsedUrl.hostname}:${parsedUrl.port}` : parsedUrl.hostname; + } catch (error) { + return ""; + } +} } From d61d292a894943a5564ee27033c5581fee2070ca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 May 2026 17:13:05 +0000 Subject: [PATCH 3/3] chore: tighten wget resolving host regex Agent-Logs-Url: https://github.com/AhmadIbrahiim/Website-downloader/sessions/7f20200c-2cfd-4ac6-958e-6256c981457e Co-authored-by: AhmadIbrahiim <17949497+AhmadIbrahiim@users.noreply.github.com> --- wget/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wget/index.js b/wget/index.js index afd1856..c83ebd2 100644 --- a/wget/index.js +++ b/wget/index.js @@ -25,7 +25,7 @@ child.stderr.on("data",(response)=>{ if(!website) { - const resolvingMatch = responseText.match(/Resolving\s+([^\s(]+)/); + const resolvingMatch = responseText.match(/Resolving\s+([^\s]+)\s+\(/); if (resolvingMatch && resolvingMatch[1]) { website = resolvingMatch[1]; }