Fixed URLs with non-default char types.

This commit is contained in:
2024-08-20 00:35:19 +02:00
parent 03f255a7d0
commit 05f0e1474a
2 changed files with 21 additions and 12 deletions

View File

@@ -79,7 +79,7 @@ constexpr void URLBase<TChar, TTraits, TAllocator>::parse() noexcept
}
string_view_t toParse = base_;
typename string_view_t::size_type pos = toParse.find(':');
typename string_view_t::size_type pos = toParse.find(TChar(':'));
if (pos == string_t::npos)
{
clear();
@@ -88,7 +88,8 @@ constexpr void URLBase<TChar, TTraits, TAllocator>::parse() noexcept
scheme_ = toParse.substr(0, pos);
toParse = toParse.substr(pos + 1);
if (!toParse.starts_with("//"))
const TChar DOUBLE_SLASH[] = {TChar('/'), TChar('/'), TChar(0)};
if (!toParse.starts_with(DOUBLE_SLASH))
{
userinfo_ = host_ = {};
port_ = 0;
@@ -96,7 +97,7 @@ constexpr void URLBase<TChar, TTraits, TAllocator>::parse() noexcept
else
{
toParse = toParse.substr(2); // skip the slashes
pos = toParse.find('/');
pos = toParse.find(TChar('/'));
if (!parseAuthority(toParse.substr(0, pos)))
{
clear();
@@ -110,7 +111,7 @@ constexpr void URLBase<TChar, TTraits, TAllocator>::parse() noexcept
toParse = toParse.substr(pos);
}
pathQueryFragment_ = toParse;
pos = toParse.find('#');
pos = toParse.find(TChar('#'));
if (pos == string_view_t::npos)
{
fragment_ = {};
@@ -120,7 +121,7 @@ constexpr void URLBase<TChar, TTraits, TAllocator>::parse() noexcept
fragment_ = toParse.substr(pos + 1);
toParse = toParse.substr(0, pos);
}
pos = toParse.find('?');
pos = toParse.find(TChar('?'));
if (pos == string_view_t::npos)
{
query_ = {};
@@ -137,7 +138,7 @@ template<typename TChar, typename TTraits, typename TAllocator>
constexpr bool URLBase<TChar, TTraits, TAllocator>::parseAuthority(string_view_t authority) noexcept
{
string_view_t toParse = authority;
typename string_view_t::size_type pos = toParse.find('@');
typename string_view_t::size_type pos = toParse.find(TChar('@'));
if (pos == string_view_t::npos)
{
userinfo_ = {};
@@ -147,7 +148,7 @@ constexpr bool URLBase<TChar, TTraits, TAllocator>::parseAuthority(string_view_t
userinfo_ = toParse.substr(0, pos);
toParse = toParse.substr(pos + 1);
}
pos = toParse.find(':'); // TODO: IPv6
pos = toParse.find(TChar(':')); // TODO: IPv6
if (pos == string_view_t::npos)
{
port_ = 0;