Finding URLs in prose is mostly a problem of knowing where one stops. A URL can legitimately contain full stops, commas, brackets, colons and question marks, and so can the sentence around it, so the end of a link and the end of a clause are genuinely ambiguous.
Trailing punctuation is the everyday failure. A link at the end of a sentence captures the full stop; a link inside brackets captures the closing bracket. Both produce an address that looks right and returns a 404. The usual convention is to strip a trailing full stop, comma or closing bracket unless the URL contains an unmatched opening bracket, which handles the common cases and is still a heuristic rather than a rule.
Bare domains are the other decision. Text often contains example.com with no scheme in front of it, which a reader recognises as a link and a strict pattern does not. Accepting them means also accepting anything that looks like a domain, including file names ending in a known extension, so a sentence mentioning a document called report.co can produce a URL that never existed.
Once extracted, two things are usually worth doing. Deduplicating with an eye to whether a trailing slash, a differing scheme, or a tracking parameter makes two URLs the same or different for your purpose. And stripping tracking parameters, since links copied from email and social platforms carry campaign identifiers that are noise in a reference list and occasionally identify the person who shared them.
A note on shortened links: they cannot be inspected without resolving them, and resolving them means requesting them, which tells the shortener that someone did. That is a decision worth making knowingly rather than as a side effect of tidying a list.
The extraction happens in the tab, so the document you are pulling links from never leaves your machine.