mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-14 12:19:59 +00:00
front/cobalt.js: actually extract the url from clipboard
This commit is contained in:
parent
9b0d968cca
commit
511ad07d2f
1 changed files with 4 additions and 3 deletions
|
@ -32,7 +32,7 @@ let store = {};
|
||||||
|
|
||||||
const validLink = (link) => {
|
const validLink = (link) => {
|
||||||
try {
|
try {
|
||||||
return /^https?:/i.test(new URL(link).protocol);
|
return /^https:/i.test(new URL(link).protocol);
|
||||||
} catch {
|
} catch {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -493,8 +493,9 @@ const download = async(url) => {
|
||||||
const pasteClipboard = async() => {
|
const pasteClipboard = async() => {
|
||||||
try {
|
try {
|
||||||
let clipboard = await navigator.clipboard.readText();
|
let clipboard = await navigator.clipboard.readText();
|
||||||
if (clipboard.test(/https?:\/\/[^\s]+/g)) {
|
let onlyURL = clipboard.match(/https:\/\/[^\s]+/g)
|
||||||
eid("url-input-area").value = text;
|
if (onlyURL) {
|
||||||
|
eid("url-input-area").value = onlyURL;
|
||||||
download(eid("url-input-area").value);
|
download(eid("url-input-area").value);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in a new issue