#pragma once // Spec: INV-social 15.5 / 16.2. The subset of Foundation URL(string:) and URLComponents the social screens use: // validity, path, query and fragment of a URL reference (absolute or "/path?x#y"). #include #include namespace dp { class UrlSyntax { public: struct Parts { std::string path; // percent-decoded std::string query; // raw, items are decoded by the caller std::optional fragment; // percent-decoded }; // nullopt for strings that are not valid URL references (empty, spaces, control and delimiter characters). static std::optional parse(const std::string& url); static bool valid(const std::string& url) { return parse(url).has_value(); } static std::string percentDecode(const std::string& in); }; } // namespace dp