| Index: url/scheme_host_port.cc
|
| diff --git a/url/scheme_host_port.cc b/url/scheme_host_port.cc
|
| index 4d0f0007595561d99bb54ffb61c57cee033b21e5..bd1fce8ed3883227aa40a059561ab886e6019360 100644
|
| --- a/url/scheme_host_port.cc
|
| +++ b/url/scheme_host_port.cc
|
| @@ -13,6 +13,7 @@
|
| #include "base/numerics/safe_conversions.h"
|
| #include "base/strings/string_number_conversions.h"
|
| #include "url/gurl.h"
|
| +#include "url/third_party/mozilla/url_parse.h"
|
| #include "url/url_canon.h"
|
| #include "url/url_canon_stdstring.h"
|
| #include "url/url_constants.h"
|
| @@ -167,6 +168,31 @@ std::string SchemeHostPort::Serialize() const {
|
| return result;
|
| }
|
|
|
| +GURL SchemeHostPort::GetURL() const {
|
| + std::string serialized = Serialize();
|
| + if (serialized.empty())
|
| + return GURL();
|
| +
|
| + static const int schemeSeparatorLength = strlen(kStandardSchemeSeparator);
|
| +
|
| + Parsed parsed;
|
| + parsed.scheme = Component(0, scheme().length());
|
| +
|
| + int host_begin = scheme().length() + schemeSeparatorLength;
|
| + parsed.host = Component(host_begin, host().length());
|
| +
|
| + if (serialized.length() > host_begin + host().length()) {
|
| + int port_begin = host_begin + host().length() + 1;
|
| + parsed.port = Component(port_begin, serialized.length() - port_begin);
|
| + }
|
| +
|
| + // Append a / on the end of the URL.
|
| + parsed.path = Component(serialized.length(), 1);
|
| + serialized.append("/");
|
| +
|
| + return GURL(serialized.data(), serialized.length(), parsed, true);
|
| +}
|
| +
|
| bool SchemeHostPort::Equals(const SchemeHostPort& other) const {
|
| return port_ == other.port() && scheme_ == other.scheme() &&
|
| host_ == other.host();
|
|
|