This commit is contained in:
Timur A. Fatkhullin
2024-10-18 00:08:06 +03:00
parent 672788d59d
commit 60fa49bc29
2 changed files with 31 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include <algorithm>
/*
@@ -63,6 +64,9 @@ public:
fromRange(ept);
}
virtual ~AdcEndpointParser() = default;
template <traits::adc_input_char_range R>
requires std::ranges::contiguous_range<R>
bool fromRange(const R& ept)
@@ -88,19 +92,23 @@ public:
_proto = std::string_view{_endpoint.begin(), found.begin()};
for (auto& valid_proto : validProtoMarks) {
_isValid = _proto == valid_proto;
if (_isValid) {
break;
}
}
// for (auto& valid_proto : validProtoMarks) {
// _isValid = _proto == valid_proto;
// if (_isValid) {
// break;
// }
// }
if (!_isValid) {
// if (!_isValid) {
// return _isValid;
// }
// _isValid = false;
if (!checkProtoMark(_proto)) {
return _isValid;
}
_isValid = false;
_host = std::string_view{found.end(), _endpoint.end()};
if (_proto == protoMarkLocal) { // local proto allows only hostname
_path = std::string_view();
@@ -220,6 +228,13 @@ protected:
int _port;
bool _isValid;
virtual bool checkProtoMark(std::string_view proto_mark)
{
return std::ranges::any_of(AdcEndpointParser::validProtoMarks,
[proto_mark](const auto& el) { return el == proto_mark; });
}
enum EndpointPart { PROTO_PART, HOST_PART, PATH_PART };
template <traits::adc_view_or_output_char_range R>