diff --git a/brave/common/extensions/url_bindings.cc b/brave/common/extensions/url_bindings.cc index 0e85c0099..e5a76b52d 100644 --- a/brave/common/extensions/url_bindings.cc +++ b/brave/common/extensions/url_bindings.cc @@ -334,14 +334,14 @@ void URLBindings::Parse( if (gurl.has_username()) dict.Set("auth", gurl.username() + (gurl.has_password() ? ":" + gurl.password() : "")); - dict.Set("hash", gurl.ref()); + dict.Set("hash", (gurl.has_ref() ? "#" : "") + gurl.ref()); dict.Set("hostname", gurl.host()); - dict.Set("host", gurl.host() + ":" + gurl.port()); + dict.Set("host", gurl.host() + (gurl.has_port() ? ":" + gurl.port() : "")); dict.Set("href", gurl.possibly_invalid_spec()); dict.Set("path", gurl.PathForRequest()); dict.Set("pathname", gurl.path()); dict.Set("port", gurl.port()); - dict.Set("protocol", gurl.scheme()); + dict.Set("protocol", gurl.scheme() + (gurl.has_scheme() ? ":" : "")); dict.Set("query", gurl.query()); dict.Set("search", "?" + gurl.query()); dict.Set("origin", gurl.GetOrigin());