summaryrefslogtreecommitdiff
path: root/indra/llui/llurlregistry.cpp
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2009-12-10 14:25:25 -0500
committerLoren Shih <seraph@lindenlab.com>2009-12-10 14:25:25 -0500
commite85cf743e51e93379f7f7afd04cdcd4b9e6b01c1 (patch)
tree11507cced90ffb96c1c7fe3d499c56eb1ff4ec4a /indra/llui/llurlregistry.cpp
parent1ca104f325d60d4f91a6227f06720977b17da1b1 (diff)
parentd575af6a6545708d05e06a1e8614a84ca5cab458 (diff)
automated merge viewer2.0->viewer2.0
Diffstat (limited to 'indra/llui/llurlregistry.cpp')
-rw-r--r--indra/llui/llurlregistry.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp
index f47db2db1a..afcff0d409 100644
--- a/indra/llui/llurlregistry.cpp
+++ b/indra/llui/llurlregistry.cpp
@@ -58,6 +58,9 @@ LLUrlRegistry::LLUrlRegistry()
//so it should be registered in the end of list
registerUrl(new LLUrlEntrySL());
registerUrl(new LLUrlEntrySLLabel());
+ // most common pattern is a URL without any protocol,
+ // e.g., "secondlife.com"
+ registerUrl(new LLUrlEntryHTTPNoProtocol());
}
LLUrlRegistry::~LLUrlRegistry()
@@ -118,10 +121,23 @@ static bool matchRegex(const char *text, boost::regex regex, U32 &start, U32 &en
return true;
}
+static bool stringHasUrl(const std::string &text)
+{
+ // fast heuristic test for a URL in a string. This is used
+ // to avoid lots of costly regex calls, BUT it needs to be
+ // kept in sync with the LLUrlEntry regexes we support.
+ return (text.find("://") != std::string::npos ||
+ text.find("www.") != std::string::npos ||
+ text.find(".com") != std::string::npos ||
+ text.find(".net") != std::string::npos ||
+ text.find(".edu") != std::string::npos ||
+ text.find(".org") != std::string::npos);
+}
+
bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LLUrlLabelCallback &cb)
{
// avoid costly regexes if there is clearly no URL in the text
- if (text.find("://") == std::string::npos)
+ if (! stringHasUrl(text))
{
return false;
}