From d7d823bdeda69ce8de8a33b90a6ec116c36ecdab Mon Sep 17 00:00:00 2001 From: yan Date: Thu, 15 Jun 2017 15:16:21 -0700 Subject: [PATCH] Make muon.url.parse work more like Node's Fix https://github.com/brave/browser-laptop/issues/9503 --- brave/common/extensions/url_bindings.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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());