Kurlyk
Toggle main menu visibility
Loading...
Searching...
No Matches
http_utils.hpp
Go to the documentation of this file.
1
#pragma once
2
#ifndef _KURLYK_UTILS_HTTP_UTILS_HPP_INCLUDED
3
#define _KURLYK_UTILS_HTTP_UTILS_HPP_INCLUDED
4
7
8
namespace
kurlyk::utils
{
9
13
inline
std::string
remove_http_prefix
(
const
std::string& url) {
14
const
std::string https_prefix =
"https://"
;
15
const
std::string http_prefix =
"http://"
;
16
17
std::string modified_url = url;
18
19
// Find the position of "https://" or "http://"
20
std::size_t pos = modified_url.find(https_prefix);
21
if
(pos == std::string::npos) {
22
pos = modified_url.find(http_prefix);
23
}
24
25
// If found, erase the substring
26
if
(pos != std::string::npos) {
27
if
(modified_url.compare(pos, https_prefix.length(), https_prefix) == 0) {
28
modified_url.erase(pos, https_prefix.length());
29
}
else
if
(modified_url.compare(pos, http_prefix.length(), http_prefix) == 0) {
30
modified_url.erase(pos, http_prefix.length());
31
}
32
}
33
34
return
modified_url;
35
}
36
37
}
// namespace kurlyk::utils
38
39
#endif
// _KURLYK_UTILS_HTTP_UTILS_HPP_INCLUDED
kurlyk::utils
Definition
Base64Url.hpp:13
kurlyk::utils::remove_http_prefix
std::string remove_http_prefix(const std::string &url)
Removes the first occurrence of "https://" or "http://" from the given URL.
Definition
http_utils.hpp:13
include
kurlyk
utils
http_utils.hpp
Generated by
1.17.0