From 0a2b98b5358fbd034870a80c9db766849c3a08b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Thu, 19 Dec 2024 11:47:56 +0100 Subject: [PATCH] net::parseUri: rename argument url to pathAndQuery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Méven Car Change-Id: Ifa832978040ab1bfa156b0c639605a0e8a971324 --- net/NetUtil.cpp | 6 +++--- net/NetUtil.hpp | 6 +++--- test/WhiteBoxTests.cpp | 44 +++++++++++++++++++++--------------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/net/NetUtil.cpp b/net/NetUtil.cpp index 9e0fc1c04e0e2..29691567785cc 100644 --- a/net/NetUtil.cpp +++ b/net/NetUtil.cpp @@ -577,7 +577,7 @@ connect(std::string uri, const std::shared_ptr& protoc } bool parseUri(std::string uri, std::string& scheme, std::string& host, std::string& port, - std::string& url) + std::string& pathAndQuery) { const auto itScheme = uri.find("://"); if (itScheme != uri.npos) @@ -594,12 +594,12 @@ bool parseUri(std::string uri, std::string& scheme, std::string& host, std::stri const auto itUrl = uri.find('/'); if (itUrl != uri.npos) { - url = uri.substr(itUrl); // Including the first foreslash. + pathAndQuery = uri.substr(itUrl); // Including the first foreslash. uri = uri.substr(0, itUrl); } else { - url.clear(); + pathAndQuery.clear(); } const auto itPort = uri.find(':'); diff --git a/net/NetUtil.hpp b/net/NetUtil.hpp index 8f1e2b96da8e0..721c655953212 100644 --- a/net/NetUtil.hpp +++ b/net/NetUtil.hpp @@ -112,14 +112,14 @@ connect(std::string uri, const std::shared_ptr& protoc /// Decomposes a URI into its components. /// Returns true if parsing was successful. bool parseUri(std::string uri, std::string& scheme, std::string& host, std::string& port, - std::string& url); + std::string& pathAndQuery); /// Decomposes a URI into its components. /// Returns true if parsing was successful. inline bool parseUri(std::string uri, std::string& scheme, std::string& host, std::string& port) { - std::string url; - return parseUri(std::move(uri), scheme, host, port, url); + std::string pathAndQuery; + return parseUri(std::move(uri), scheme, host, port, pathAndQuery); } /// Return the locator given a URI. diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp index 0ad7fc4ae761a..6877092e2ebc7 100644 --- a/test/WhiteBoxTests.cpp +++ b/test/WhiteBoxTests.cpp @@ -1099,72 +1099,72 @@ void WhiteBoxTests::testParseUriUrl() std::string scheme = "***"; std::string host = "***"; std::string port = "***"; - std::string url = "***"; + std::string pathAndQuery = "***"; - LOK_ASSERT(!net::parseUri(std::string(), scheme, host, port, url)); + LOK_ASSERT(!net::parseUri(std::string(), scheme, host, port, pathAndQuery)); LOK_ASSERT(scheme.empty()); LOK_ASSERT(host.empty()); LOK_ASSERT(port.empty()); - LOK_ASSERT(url.empty()); + LOK_ASSERT(pathAndQuery.empty()); - LOK_ASSERT(net::parseUri("localhost", scheme, host, port, url)); + LOK_ASSERT(net::parseUri("localhost", scheme, host, port, pathAndQuery)); LOK_ASSERT(scheme.empty()); LOK_ASSERT_EQUAL(std::string("localhost"), host); LOK_ASSERT(port.empty()); - LOK_ASSERT(url.empty()); + LOK_ASSERT(pathAndQuery.empty()); - LOK_ASSERT(net::parseUri("127.0.0.1", scheme, host, port, url)); + LOK_ASSERT(net::parseUri("127.0.0.1", scheme, host, port, pathAndQuery)); LOK_ASSERT(scheme.empty()); LOK_ASSERT_EQUAL(std::string("127.0.0.1"), host); LOK_ASSERT(port.empty()); - LOK_ASSERT(url.empty()); + LOK_ASSERT(pathAndQuery.empty()); - LOK_ASSERT(net::parseUri("domain.com", scheme, host, port, url)); + LOK_ASSERT(net::parseUri("domain.com", scheme, host, port, pathAndQuery)); LOK_ASSERT(scheme.empty()); LOK_ASSERT_EQUAL(std::string("domain.com"), host); LOK_ASSERT(port.empty()); - LOK_ASSERT(url.empty()); + LOK_ASSERT(pathAndQuery.empty()); - LOK_ASSERT(net::parseUri("127.0.0.1:9999", scheme, host, port, url)); + LOK_ASSERT(net::parseUri("127.0.0.1:9999", scheme, host, port, pathAndQuery)); LOK_ASSERT(scheme.empty()); LOK_ASSERT_EQUAL(std::string("127.0.0.1"), host); LOK_ASSERT_EQUAL(std::string("9999"), port); - LOK_ASSERT(url.empty()); + LOK_ASSERT(pathAndQuery.empty()); - LOK_ASSERT(net::parseUri("domain.com:88", scheme, host, port, url)); + LOK_ASSERT(net::parseUri("domain.com:88", scheme, host, port, pathAndQuery)); LOK_ASSERT(scheme.empty()); LOK_ASSERT_EQUAL(std::string("domain.com"), host); LOK_ASSERT_EQUAL(std::string("88"), port); - LOK_ASSERT(url.empty()); + LOK_ASSERT(pathAndQuery.empty()); - LOK_ASSERT(net::parseUri("http://domain.com", scheme, host, port, url)); + LOK_ASSERT(net::parseUri("http://domain.com", scheme, host, port, pathAndQuery)); LOK_ASSERT_EQUAL(std::string("http://"), scheme); LOK_ASSERT_EQUAL(std::string("domain.com"), host); LOK_ASSERT(port.empty()); - LOK_ASSERT(url.empty()); + LOK_ASSERT(pathAndQuery.empty()); - LOK_ASSERT(net::parseUri("https://domain.com:88", scheme, host, port, url)); + LOK_ASSERT(net::parseUri("https://domain.com:88", scheme, host, port, pathAndQuery)); LOK_ASSERT_EQUAL(std::string("https://"), scheme); LOK_ASSERT_EQUAL(std::string("domain.com"), host); LOK_ASSERT_EQUAL(std::string("88"), port); - LOK_ASSERT(net::parseUri("http://domain.com/path/to/file", scheme, host, port, url)); + LOK_ASSERT(net::parseUri("http://domain.com/path/to/file", scheme, host, port, pathAndQuery)); LOK_ASSERT_EQUAL(std::string("http://"), scheme); LOK_ASSERT_EQUAL(std::string("domain.com"), host); LOK_ASSERT(port.empty()); - LOK_ASSERT_EQUAL(std::string("/path/to/file"), url); + LOK_ASSERT_EQUAL(std::string("/path/to/file"), pathAndQuery); - LOK_ASSERT(net::parseUri("https://domain.com:88/path/to/file", scheme, host, port, url)); + LOK_ASSERT(net::parseUri("https://domain.com:88/path/to/file", scheme, host, port, pathAndQuery)); LOK_ASSERT_EQUAL(std::string("https://"), scheme); LOK_ASSERT_EQUAL(std::string("domain.com"), host); LOK_ASSERT_EQUAL(std::string("88"), port); - LOK_ASSERT_EQUAL(std::string("/path/to/file"), url); + LOK_ASSERT_EQUAL(std::string("/path/to/file"), pathAndQuery); - LOK_ASSERT(net::parseUri("wss://127.0.0.1:9999/", scheme, host, port, url)); + LOK_ASSERT(net::parseUri("wss://127.0.0.1:9999/", scheme, host, port, pathAndQuery)); LOK_ASSERT_EQUAL(std::string("wss://"), scheme); LOK_ASSERT_EQUAL(std::string("127.0.0.1"), host); LOK_ASSERT_EQUAL(std::string("9999"), port); - LOK_ASSERT_EQUAL(std::string("/"), url); + LOK_ASSERT_EQUAL(std::string("/"), pathAndQuery); } void WhiteBoxTests::testParseUrl()