mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
update code style and add docs+tests for uri::get_query references #298
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
HEAD
|
||||
- Adds URI method to extract query string from URI.
|
||||
- Numerous performance improvements. Including: tuned default buffer sizes based
|
||||
on profiling, caching of handler binding for async reads/writes, non-malloc
|
||||
allocators for read/write handlers, disabling of a number of questionably
|
||||
|
||||
@@ -43,6 +43,7 @@ BOOST_AUTO_TEST_CASE( uri_valid ) {
|
||||
BOOST_CHECK_EQUAL( uri.get_host(), "localhost");
|
||||
BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
|
||||
BOOST_CHECK_EQUAL( uri.get_resource(), "/chat" );
|
||||
BOOST_CHECK_EQUAL( uri.get_query(), "" );
|
||||
}
|
||||
|
||||
// Test a regular valid ws URI
|
||||
@@ -201,6 +202,7 @@ BOOST_AUTO_TEST_CASE( uri_valid_4 ) {
|
||||
BOOST_CHECK_EQUAL( uri.get_host(), "localhost");
|
||||
BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
|
||||
BOOST_CHECK_EQUAL( uri.get_resource(), "/chat/foo/bar?foo=bar" );
|
||||
BOOST_CHECK_EQUAL( uri.get_query(), "foo=bar" );
|
||||
}
|
||||
|
||||
// Valid URI with a mapped v4 ipv6 literal
|
||||
|
||||
@@ -281,16 +281,23 @@ public:
|
||||
s << m_resource;
|
||||
return s.str();
|
||||
}
|
||||
|
||||
std::string const get_query() const {
|
||||
std::size_t found = m_resource.find("?");
|
||||
if (found > 0)
|
||||
|
||||
/// Return the query portion
|
||||
/**
|
||||
* Returns the query portion (after the ?) of the URI or an empty string if
|
||||
* there is none.
|
||||
*
|
||||
* @return query portion of the URI.
|
||||
*/
|
||||
std::string get_query() const {
|
||||
std::size_t found = m_resource.find('?');
|
||||
if (found != std::string::npos) {
|
||||
return m_resource.substr(found + 1);
|
||||
else
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// get query?
|
||||
// get fragment
|
||||
|
||||
// hi <3
|
||||
|
||||
Reference in New Issue
Block a user