Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
url-parts.hh
Go to the documentation of this file.
1#pragma once
3
4#include <string>
5#include <regex>
6
7namespace nix {
8
9// URI stuff.
10const static std::string pctEncoded = "(?:%[0-9a-fA-F][0-9a-fA-F])";
11const static std::string schemeNameRegex = "(?:[a-z][a-z0-9+.-]*)";
12const static std::string ipv6AddressSegmentRegex = "[0-9a-fA-F:]+(?:%\\w+)?";
13const static std::string ipv6AddressRegex = "(?:\\[" + ipv6AddressSegmentRegex + "\\]|" + ipv6AddressSegmentRegex + ")";
14const static std::string unreservedRegex = "(?:[a-zA-Z0-9-._~])";
15const static std::string subdelimsRegex = "(?:[!$&'\"()*+,;=])";
16const static std::string hostnameRegex = "(?:(?:" + unreservedRegex + "|" + pctEncoded + "|" + subdelimsRegex + ")*)";
17const static std::string hostRegex = "(?:" + ipv6AddressRegex + "|" + hostnameRegex + ")";
18const static std::string userRegex = "(?:(?:" + unreservedRegex + "|" + pctEncoded + "|" + subdelimsRegex + "|:)*)";
19const static std::string authorityRegex = "(?:" + userRegex + "@)?" + hostRegex + "(?::[0-9]+)?";
20const static std::string pcharRegex = "(?:" + unreservedRegex + "|" + pctEncoded + "|" + subdelimsRegex + "|[:@])";
21const static std::string queryRegex = "(?:" + pcharRegex + "|[/? \"])*";
22const static std::string fragmentRegex = "(?:" + pcharRegex + "|[/? \"^])*";
23const static std::string segmentRegex = "(?:" + pcharRegex + "*)";
24const static std::string absPathRegex = "(?:(?:/" + segmentRegex + ")*/?)";
25const static std::string pathRegex = "(?:" + segmentRegex + "(?:/" + segmentRegex + ")*/?)";
26
30const static std::string refRegexS = "[a-zA-Z0-9@][a-zA-Z0-9_.\\/@+-]*";
31extern std::regex refRegex;
32
36const static std::string badGitRefRegexS = "//|^[./]|/\\.|\\.\\.|[[:cntrl:][:space:]:?^~\[]|\\\\|\\*|\\.lock$|\\.lock/|@\\{|[/.]$|^@$|^$";
37extern std::regex badGitRefRegex;
38
40const static std::string revRegexS = "[0-9a-fA-F]{40}";
41extern std::regex revRegex;
42
44const static std::string refAndOrRevRegex = "(?:(" + revRegexS + ")|(?:(" + refRegexS + ")(?:/(" + revRegexS + "))?))";
45
46}