From 511ad07d2f1d13f417271a3e66a213aa6fd9c1b1 Mon Sep 17 00:00:00 2001 From: wukko Date: Tue, 30 Apr 2024 00:34:29 +0600 Subject: [PATCH] front/cobalt.js: actually extract the url from clipboard --- src/front/cobalt.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/front/cobalt.js b/src/front/cobalt.js index 3a07dc88..0fd638f2 100644 --- a/src/front/cobalt.js +++ b/src/front/cobalt.js @@ -32,7 +32,7 @@ let store = {}; const validLink = (link) => { try { - return /^https?:/i.test(new URL(link).protocol); + return /^https:/i.test(new URL(link).protocol); } catch { return false } @@ -493,8 +493,9 @@ const download = async(url) => { const pasteClipboard = async() => { try { let clipboard = await navigator.clipboard.readText(); - if (clipboard.test(/https?:\/\/[^\s]+/g)) { - eid("url-input-area").value = text; + let onlyURL = clipboard.match(/https:\/\/[^\s]+/g) + if (onlyURL) { + eid("url-input-area").value = onlyURL; download(eid("url-input-area").value); } } catch (e) {