pixwhile/blankie/murl.h

39 lines
768 B
C++

#pragma once
#include <string>
namespace blankie {
namespace murl {
struct Url {
std::string scheme;
std::string userinfo;
std::string hostname;
int port; // -1 if unspecified
std::string path;
std::string query;
std::string fragment;
Url(const std::string& str);
constexpr std::string get_origin() const {
std::string res;
if (!this->scheme.empty()) {
res = this->scheme + "://";
}
res += this->hostname;
if (this->port != -1) {
res += ':';
res += std::to_string(this->port);
}
return res;
}
std::string to_string() const;
};
std::string normalize_path(const std::string& str);
}; // namespace murl
}; // namespace blankie