From e2fe4bf92cbf9b5803b2956c6b8c0019fe9a54c6 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Fri, 19 May 2023 21:44:14 -0700 Subject: [PATCH] Make the URL in the success message clickable --- functions/api.js | 2 +- script.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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) { -- 2.47.3