Request get_path now has 2 optional parameters for beginning and end slash placements.

This commit is contained in:
Relintai 2022-02-06 10:54:42 +01:00
parent 1476a89304
commit 28d53b16f4
2 changed files with 12 additions and 4 deletions

View File

@ -188,12 +188,20 @@ void Request::setup_url_stack() {
}
}
String Request::get_path() const {
String path = "";
String Request::get_path(const bool beginning_slash, const bool end_slash) const {
String path;
if (beginning_slash) {
path += '/';
}
for (uint32_t i = _path_stack_pointer; i < _path_stack.size(); ++i) {
path += _path_stack[i];
path += "/";
path += '/';
}
if (!end_slash && path.size() > 1) {
path.pop_back();
}
return path;

View File

@ -67,7 +67,7 @@ public:
virtual String get_host() const;
void setup_url_stack();
String get_path() const;
String get_path(const bool beginning_slash = false, const bool end_slash = true) const;
virtual const String &get_path_full() const;
const String &get_path_segment(const uint32_t i) const;
const String &get_current_path_segment() const;