Skip to content
LeviMC
English
AutoLightDark
LeviLamina
Loading...
Searching...
No Matches
Url.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated forward declare list
6// clang-format off
7namespace Util::ResourceUri { struct ValidationResult; }
8namespace Util::Url { struct Components; }
9namespace Util::Url { struct ComponentsView; }
10// clang-format on
11
12namespace Util::Url {
13// functions
14// NOLINTBEGIN
15MCNAPI ::std::string anonymizeIPAddress(::std::string const& ipAddress);
16
17MCNAPI ::std::string anonymizeIPv6Address(::std::string const& ipAddress);
18
19MCNAPI ::std::string append(::std::string const& lhs, ::std::string const& rhs);
20
21#ifdef LL_PLAT_C
22MCNAPI ::std::string appendQueryString(::std::string const& url, ::std::string const& query);
23
24MCNAPI ::std::string assembleUrl(::Util::Url::ComponentsView const& components);
25
26MCNAPI ::std::string buildMailtoUrl(::std::string const& subject, ::std::string const& body);
27
28MCNAPI bool doesRouteMatch(::std::string_view routePattern, ::std::string_view route);
29
30MCNAPI ::std::string extractAuthorityAndPathFromUrl(::std::string const& url);
31
32MCNAPI ::std::optional<::std::string> getExtension(::std::string const& url);
33
34MCNAPI bool getIPv4LabelValues(::std::string const& ipAddrStr, ::std::vector<uint64>& outLabels);
35
36MCNAPI bool getIPv6LabelValues(::std::string const& ipAddrStr, ::std::vector<uint64>& outLabels);
37
38MCNAPI ::std::vector<::std::pair<::std::string_view, ::std::string_view>> getQueryParameters(::std::string_view url);
39
40MCNAPI ::std::string getUncompressedIPv6Address(::std::string const& ipAddrStr);
41
42MCNAPI bool isAddressLocalhost(::std::string const& ipAddrStr);
43
44MCNAPI bool isAddressPrivateNetwork(::std::string const& ipAddrStr);
45
46MCNAPI bool
47isAddressWithinCIDRMasks_IPv4(::std::string const& ipAddrStr, ::std::vector<::std::string> const& ipAddressCIDRMasks);
48
49MCNAPI bool
50isAddressWithinCIDRMasks_IPv6(::std::string const& ipAddrStr, ::std::vector<::std::string> const& ipAddressCIDRMasks);
51
52MCNAPI bool isValidHostname(::std::string_view address);
53
54MCNAPI bool isValidIP(::std::string_view ipAddrStr, bool considerIPv4Valid, bool considerIPv6Valid);
55#endif
56
57MCNAPI bool isValidIPv4(::std::string_view ipAddrStr);
58
59MCNAPI bool isValidIPv6(::std::string_view ipAddrStr);
60
61#ifdef LL_PLAT_C
62MCNAPI bool parseOutCIDRValue(::std::string& modifiableAddress, int& CIDRValue);
63#endif
64
65MCNAPI ::Util::Url::ComponentsView parseUrl(::std::string_view url);
66
67MCNAPI ::std::string setQueryParameter(::std::string_view url, ::std::string_view key, ::std::string_view value);
68
69#ifdef LL_PLAT_C
70MCNAPI bool startsWithMatchingFullPathSegments(::std::string_view route, ::std::string_view start);
71
72MCNAPI ::std::string stripProtocol(::std::string const& url);
73#endif
74
75MCNAPI ::std::string stripQueryParameters(::std::string const& url);
76
77#ifdef LL_PLAT_C
78MCNAPI ::std::optional<::std::string> urlDecode(::std::string_view value, bool replacePlusWithSpace);
79#endif
80
81MCNAPI ::std::string urlEncode(::std::string_view value, ::std::function<bool(uchar)> isAlphaNum);
82
83MCNAPI ::Util::ResourceUri::ValidationResult validateAbsoluteUrl(::std::string const& url);
84// NOLINTEND
85
86// static variables
87// NOLINTBEGIN
88MCNAPI ::Util::Url::Components const& EMPTY_URL();
89// NOLINTEND
90
91} // namespace Util::Url
Definition ValidationResult.h:7
Definition ComponentsView.h:12
Definition Components.h:12