Grabs email addresses too
|
|
The regex used (good job on making that readable, BTW) grabs embedded email address too with the section to allow usernames. I'm not sure this is a good thing, especially since those links come out as e.g. <http://sample_user@hotmail.com/> (from a forum link to MSN Messenger -- <http://members.msn.com/sample_user@hotmail.com>). Now, according to the specs, of course, that's a perfectly well-formed URL -- but in practice, it's VERY unlikely it's actually a URL. I have two suggestions for correcting this. The first possibility is to try to detect email addresses and give them the right mailto: protocol. The other possibility is to simply discard them.
|
|
|
Hm, thanks for the comment. It is always a dilemma whether one should handle some cases differently based on probability. I have had similar thoughts regarding the .do extension, but decided to not make any exceptions. The case you mention could be more eligible though. The question is, how often does this case occur? My guess is that an URL with an email address is not very common. On the other hand, as you say, how often is it an URL with a username? A third alternative would be to link to both the http: and mailto: versions (if it is a valid email address). |
|
|
I have now changed the script so that foo@bar.com is treated as an email address. However, I made the http:// interpretation available by interchanging between the two on mouseout. Email addresses are distinguished from other links by having caption "@". I hope this works, and that the onmouseout change doesn't confuse too much. |
|
|
The onmouseout change is a bit confusing at first, but for your target audience of power users I don't think it matters much. At any rate, I greatly appreciate the change. |