Action
Copy URL in Current Line
If there is a URL in the current line of text in the editor, copy it to the clipboard. No need to select the URL.
If no URL is found, fail.
Steps
-
script
// get selection let [st,len] = editor.getSelectedLineRange() let line = editor.getTextInRange(st,len) // url regex let re = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/ let fl = false for(let s of line.split(/\s+/)) { if (s.match(re)) { app.setClipboard(s) app.displaySuccessMessage("URL Copied") fl = true break } } if (!fl) { context.fail() }
Options
-
After Success Nothing Notification Error Log Level None
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.