Overview
What Extract URLs does
Finds HTTP, HTTPS, and www-style links, removes surrounding sentence punctuation, preserves balanced URL brackets, and returns one unique URL per line.
| Category | Text Editing & Formatting |
|---|---|
| Action type | JavaScript |
| Result | Copy the result |
| Internet | Not required |
Example
Action and outcome
| Action | Outcome |
|---|---|
| Extract URLsSelected text: See https://example.com/docs, then https://actionclip.app. | https://example.com/docs https://actionclip.app |
Workflow
Use Extract URLs
Follow these steps to extract unique web URLs from selected text with ActionClip.
- Select the text you want to use.
- Choose Extract URLs from ActionClip.
- Review the result, then copy it where you need it.
Before you add it
Requirements and privacy
- Before you start: No setup required.
- Your selected text: Runs locally in ActionClip’s JavaScript sandbox. Selected text does not leave your Mac.
Inspect before installing
Action configuration
The definition below is included so you can inspect how the action works before downloading it.
JavaScript definition
function run(selected_text) {
const matches = selected_text.match(/\bhttps?:\/\/[^\s<>"']+|\bwww\.[^\s<>"']+/gi) || [];
function trimTrailingPunctuation(value) {
let result = value.replace(/[.,;:!?]+$/g, "");
const pairs = [["(", ")"], ["[", "]"], ["{", "}"]];
pairs.forEach(([opening, closing]) => {
while (result.endsWith(closing)) {
const opens = result.split(opening).length - 1;
const closes = result.split(closing).length - 1;
if (closes <= opens) break;
result = result.slice(0, -1);
}
});
return result;
}
const seen = new Set();
const urls = [];
matches.map(trimTrailingPunctuation).forEach((url) => {
if (!seen.has(url)) {
seen.add(url);
urls.push(url);
}
});
return urls.length ? urls.join("\n") : "No URLs found.";
}