Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Vinnie Falco vinniefalco

🏠
Working from home
Block or report user

Report or block vinniefalco

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:8055ab496456777c35a4c28a41223a57
/** Set the port.
The port of the URL is set to the specified
which must have the <em>port</em> syntax:
@li If the string is empty, the port is
cleared including the leading colon (':'). If
the port was the last remaining portion of
the authority, then the entire authority is
removed including the leading double slash ('//').
View gist:f59c7a7d20121c786091f21ca8add2c0
void
testPath()
{
// path-empty
BOOST_TEST(value("").set_encoded_path("").encoded_url() == "");
BOOST_TEST(value("//x#").set_encoded_path("").encoded_url() == "//x#");
// path-abempty
BOOST_TEST(value("//x#").set_encoded_path("/").encoded_url() == "//x/#");
BOOST_TEST(value("//x#").set_encoded_path("//").encoded_url() == "//x//#");
View gist:b7ab3d93bcb0813a312da78f2e61fa54
// path-empty
BOOST_TEST(value("").set_encoded_path("").encoded_url() == "");
BOOST_TEST(value("//x#").set_encoded_path("").encoded_url() == "//x#");
// path-abempty
BOOST_TEST(value("//x#").set_encoded_path("/").encoded_url() == "//x/#");
BOOST_TEST(value("//x#").set_encoded_path("//").encoded_url() == "//x//#");
BOOST_TEST(value("//x#").set_encoded_path("/y").encoded_url() == "//x/y#");
BOOST_TEST_THROWS(value("//x#").set_encoded_path("x"), invalid_part);
BOOST_TEST_THROWS(value("//x#").set_encoded_path("x/"), invalid_part);
View gist:b05b6a21325d761d1960d8d319785483
//------------------------------------------------------
//
// fragment
//
//------------------------------------------------------
/** Return the fragment.
This function returns the fragment of the URL:
View gist:0c4f7d4b80e980c800554d44a6e93c21
namespace url {
class basic_value
{
public:
basic_value() = default;
// return the hostname
string_view
encoded_hostname() const noexcept
View gist:eb60c5f365fd100fa41ad36458f639be
namespace url {
class basic_value
{
char* s_;
public:
// construct a URL from a string.
// the string is copied.
basic_value( string_view s );
View gist:769c92afe592f681fcb31d63c3391de2
namespace url {
class basic_value
{
char* s_;
public:
// construct a URL from a string.
// the string is copied.
basic_value( string_view s );
View gist:2b4dfb5aef91c8d9c66b9f8f7cb441ff
namespace url {
class basic_value
{
char* s_;
protected:
virtual
char*
reserve(
View gist:8ca5a0b111f49ec497a098170062a146
namespace url {
class basic_value
{
char* s_;
protected:
virtual
char*
reserve(
View gist:d0dd4b2f9b5856de3cfcb564c6b64095
// return `true` if the hex
// word could be 0..255 if
// interpreted as decimal
bool
maybe_octet(long word)
{
if(word > 0x255)
return false;
unsigned short d1 =
(word >> 8) & 0xf;
You can’t perform that action at this time.