Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/core/uri/include/sourcemeta/core/uri.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,34 @@ class SOURCEMETA_CORE_URI_EXPORT URI {
/// ```
static auto canonicalize(std::string_view input) -> std::string;

/// Check if the given string is a valid absolute URI (has a scheme) per
/// RFC 3986 without constructing a full URI object. For example:
///
/// ```cpp
/// #include <sourcemeta/core/uri.h>
/// #include <cassert>
///
/// assert(sourcemeta::core::URI::is_uri("https://example.com/path"));
/// assert(!sourcemeta::core::URI::is_uri("://bad"));
/// assert(!sourcemeta::core::URI::is_uri("relative/path"));
/// ```
[[nodiscard]] static auto is_uri(std::string_view input) noexcept -> bool;

/// Check if the given string is a valid URI reference per RFC 3986
/// (absolute or relative) without constructing a full URI object.
/// For example:
///
/// ```cpp
/// #include <sourcemeta/core/uri.h>
/// #include <cassert>
///
/// assert(sourcemeta::core::URI::is_uri_reference("https://example.com"));
/// assert(sourcemeta::core::URI::is_uri_reference("relative/path"));
/// assert(!sourcemeta::core::URI::is_uri_reference("://bad"));
/// ```
[[nodiscard]] static auto is_uri_reference(std::string_view input) noexcept
-> bool;

private:
auto parse(std::string_view input) -> void;

Expand Down
Loading
Loading