15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2010 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef NET_TOOLS_DUMP_CACHE_URL_UTILITIES_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define NET_TOOLS_DUMP_CACHE_URL_UTILITIES_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace net { 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct UrlUtilities { 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Gets the host from an url, strips the port number as well if the url 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // has one. 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // For example: calling GetUrlHost(www.foo.com:8080/boo) returns www.foo.com 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static std::string GetUrlHost(const std::string& url); 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Get the host + path portion of an url 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // e.g http://www.foo.com/path 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // returns www.foo.com/path 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static std::string GetUrlHostPath(const std::string& url); 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Gets the path portion of an url. 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // e.g http://www.foo.com/path 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // returns /path 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static std::string GetUrlPath(const std::string& url); 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Unescape a url, converting all %XX to the the actual char 0xXX. 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // For example, this will convert "foo%21bar" to "foo!bar". 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static std::string Unescape(const std::string& escaped_url); 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace net 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // NET_TOOLS_DUMP_CACHE_URL_UTILITIES_H_ 36