From: Ardis Lu Date: Sat, 20 May 2023 04:44:14 +0000 (-0700) Subject: Make the URL in the success message clickable X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=e2fe4bf92cbf9b5803b2956c6b8c0019fe9a54c6;p=alu.bz Make the URL in the success message clickable --- diff --git a/functions/api.js b/functions/api.js index ee0bd03..087dd5a 100644 --- a/functions/api.js +++ b/functions/api.js @@ -80,5 +80,5 @@ export async function onRequestPost({ request, env }) { } await env.links.put(shortUrl, fullUrl); - return new Response(`Successfully created short URL: https://alu.bz/${shortUrl}`, { headers: { 'Content-Type': 'text/plain; charset=UTF-8' } }); + return new Response(shortUrl, { headers: { 'Content-Type': 'text/plain; charset=UTF-8' } }); } diff --git a/script.js b/script.js index db316cd..a307d23 100644 --- a/script.js +++ b/script.js @@ -102,11 +102,13 @@ async function handleSubmit(event) { if (response.ok) { statusOutput.classList.add('success'); + const generatedUrl = await response.text(); + statusOutput.innerHTML = `Successfully created short URL: ${location.origin}/${generatedUrl}`; } else { statusOutput.classList.add('failure'); + statusOutput.textContent = await response.text(); } - statusOutput.textContent = await response.text(); } if (window.ethereum !== undefined) {