What method is used by Discourse to identify urls in post body

I guess you want to extract all the links inside the post for the feature Preventing malicious linking - #27 by Sudaraka. You can get it simply by doc.css("a[href]") using Nokogiri module.

example
https://github.com/discourse/discourse/blob/b3b55e18d1c804982eef5a1b4264234e5a5a335f/lib/cooked_post_processor.rb#L154-L155

5 Likes