diff options
Diffstat (limited to 'net/tools/flip_server/url_utilities.h')
-rw-r--r-- | net/tools/flip_server/url_utilities.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/net/tools/flip_server/url_utilities.h b/net/tools/flip_server/url_utilities.h index 488753c..52a768a 100644 --- a/net/tools/flip_server/url_utilities.h +++ b/net/tools/flip_server/url_utilities.h @@ -11,55 +11,55 @@ namespace net { struct UrlUtilities { // Get the host from an url - static string GetUrlHost(const string& url) { + static std::string GetUrlHost(const std::string& url) { size_t b = url.find("//"); - if (b == string::npos) + if (b == std::string::npos) b = 0; else b += 2; size_t next_slash = url.find_first_of('/', b); size_t next_colon = url.find_first_of(':', b); - if (next_slash != string::npos - && next_colon != string::npos + if (next_slash != std::string::npos + && next_colon != std::string::npos && next_colon < next_slash) { - return string(url, b, next_colon - b); + return std::string(url, b, next_colon - b); } - if (next_slash == string::npos) { - if (next_colon != string::npos) { - return string(url, next_colon - b); + if (next_slash == std::string::npos) { + if (next_colon != std::string::npos) { + return std::string(url, next_colon - b); } else { next_slash = url.size(); } } - return string(url, b, next_slash - b); + return std::string(url, b, next_slash - b); } // Get the host + path portion of an url // e.g http://www.foo.com/path // returns www.foo.com/path - static string GetUrlHostPath(const string& url) { + static std::string GetUrlHostPath(const std::string& url) { size_t b = url.find("//"); - if (b == string::npos) + if (b == std::string::npos) b = 0; else b += 2; - return string(url, b); + return std::string(url, b); } // Get the path portion of an url // e.g http://www.foo.com/path // returns /path - static string GetUrlPath(const string& url) { + static std::string GetUrlPath(const std::string& url) { size_t b = url.find("//"); - if (b == string::npos) + if (b == std::string::npos) b = 0; else b += 2; b = url.find("/", b+1); - if (b == string::npos) + if (b == std::string::npos) return "/"; - return string(url, b); + return std::string(url, b); } }; |