From cae439ed88acefc5bf301d251a5ef68b5475f2c4 Mon Sep 17 00:00:00 2001 From: huchenlei Date: Fri, 14 Jul 2023 00:50:03 -0400 Subject: [PATCH] :bug: Explicitly handle clipboard API not available case --- javascript/api_payload_display.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/javascript/api_payload_display.js b/javascript/api_payload_display.js index d9439d3..d239132 100644 --- a/javascript/api_payload_display.js +++ b/javascript/api_payload_display.js @@ -25,6 +25,10 @@ async function copyText(copyText, copyButton) { try { + if (!navigator.clipboard) { + throw ('Clipboard API not available, please make sure you are using HTTPS.'); + } + await navigator.clipboard.writeText(copyText); copyButton.innerHTML = "Copied!"; copyButton.classList.add('success');