I found a lot of answers to detect url in text. I tried them but failed to detect protocol optional urls. Most of existing solutions could find urls in "Hello, open http://somesite.com/etc to see my photo" and replace the http part to tags. But they could not work for cases like "Hey, open somesite.com or somesite.com/etc to take a look."
How can I detect both cases (better with one regex), and the default protocol is "http://" for none-protocol urls.
I note that SO also failed to detect the latter case...
Edit: Maybe it is error-prone to change somesite.com into urls (in English), so this requirement is not ideal?
I used regex /(https?://[^\s]+)/g. This one is simple and support cases like http://abcd.com/etc/?v=3&type=xyz. But I don't know how to change it to support protocol absent case.