aboutsummaryrefslogtreecommitdiff
path: root/src/net/host.h
blob: c96a7b4340abace5619467e6ff2ef3dfa6fdfd47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#pragma once

#include <string>

namespace net
{
    /*!
    * \brief Canonicalize a hostname by converting letters to lowercase.
    *
    * \param host Hostname to canonicalize in-place.
    */
    inline void canonicalize_host(std::string& host) noexcept
    {
        for (char& c : host)
        {
            if ('A' <= c && c <= 'Z')
                c = static_cast<char>(c - 'A' + 'a');
        }
    }
}