From 1ab022df432b529fffb3a7f0772dff16a2c195ed Mon Sep 17 00:00:00 2001 From: Lynx Linden Date: Thu, 10 Dec 2009 15:33:05 +0000 Subject: EXT-3122: Added support for URLs without an explicit protocol. You can now enter URLs like "www.google.com", "secondlife.com", or "www.google.com/search?q=second%20life" and these will be hyperlinked. --- indra/llui/llurlentry.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'indra/llui/llurlentry.cpp') diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 7694d02837..7350457274 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -196,6 +196,31 @@ std::string LLUrlEntryHTTPLabel::getUrl(const std::string &string) return getUrlFromWikiLink(string); } +// +// LLUrlEntryHTTPNoProtocol Describes generic Urls like www.google.com +// +LLUrlEntryHTTPNoProtocol::LLUrlEntryHTTPNoProtocol() +{ + mPattern = boost::regex("(\\bwww\\.\\S+\\.\\S+|\\S+.com\\S*|\\S+.net\\S*|\\S+.edu\\S*|\\S+.org\\S*)", + boost::regex::perl|boost::regex::icase); + mMenuName = "menu_url_http.xml"; + mTooltip = LLTrans::getString("TooltipHttpUrl"); +} + +std::string LLUrlEntryHTTPNoProtocol::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +{ + return unescapeUrl(url); +} + +std::string LLUrlEntryHTTPNoProtocol::getUrl(const std::string &string) +{ + if (string.find("://") == std::string::npos) + { + return "http://" + escapeUrl(string); + } + return escapeUrl(string); +} + // // LLUrlEntrySLURL Describes generic http: and https: Urls // -- cgit v1.2.3