diff options
author | Qyriad <qyriad@qyriad.me> | 2024-04-30 18:11:14 -0600 |
---|---|---|
committer | Qyriad <qyriad@qyriad.me> | 2024-04-30 18:11:14 -0600 |
commit | 1425aa0b7cd0d3477589f75bea4fb9c74e057fed (patch) | |
tree | 80bb09919acabf760bd948a29901b2a67d409322 /src/libutil/url-name.hh | |
parent | e2ab89a74b1d6044cea91e91f5c3d5fce203c2e8 (diff) |
implement parsing human-readable names from URLs
Based off of commit 257b768436a0e8ab7887f9b790c5b92a7fe51ef5
Upstream-PR: https://github.com/NixOS/nix/pull/8678
Co-authored-by: Felix Uhl <felix.uhl@outlook.com>
Change-Id: Idcb7f6191ca3310ef9dc854197f7798260c3f71d
Diffstat (limited to 'src/libutil/url-name.hh')
-rw-r--r-- | src/libutil/url-name.hh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libutil/url-name.hh b/src/libutil/url-name.hh new file mode 100644 index 000000000..3a3f88e76 --- /dev/null +++ b/src/libutil/url-name.hh @@ -0,0 +1,26 @@ +#pragma once +///@file url-name.hh, for some hueristic-ish URL parsing. + +#include <string> +#include <optional> + +#include "url.hh" +#include "url-parts.hh" +#include "util.hh" +#include "split.hh" + +namespace nix { + +/** + * Try to extract a reasonably unique and meaningful, human-readable + * name of a flake output from a parsed URL. + * When nullopt is returned, the callsite should use information available + * to it outside of the URL to determine a useful name. + * This is a heuristic approach intended for user interfaces. + * @return nullopt if the extracted name is not useful to identify a + * flake output, for example because it is empty or "default". + * Otherwise returns the extracted name. + */ +std::optional<std::string> getNameFromURL(ParsedURL const & url); + +} |