mirror of
https://github.com/NixOS/nix
synced 2025-06-29 02:11:15 +02:00
Have splitPrefix
and splitPrefixTo
parser helpers
This commit is contained in:
parent
a7cd7425d9
commit
13796be78d
3 changed files with 15 additions and 9 deletions
|
@ -136,7 +136,7 @@ Hash Hash::parseSRI(std::string_view original) {
|
|||
auto rest = original;
|
||||
|
||||
// Parse the has type before the separater, if there was one.
|
||||
auto hashRaw = splitPrefix(rest, '-');
|
||||
auto hashRaw = splitPrefixTo(rest, '-');
|
||||
if (!hashRaw)
|
||||
throw BadHash("hash '%s' is not SRI", original);
|
||||
HashType parsedType = parseHashType(*hashRaw);
|
||||
|
@ -151,10 +151,10 @@ static std::pair<std::optional<HashType>, bool> getParsedTypeAndSRI(std::string_
|
|||
// Parse the has type before the separater, if there was one.
|
||||
std::optional<HashType> optParsedType;
|
||||
{
|
||||
auto hashRaw = splitPrefix(rest, ':');
|
||||
auto hashRaw = splitPrefixTo(rest, ':');
|
||||
|
||||
if (!hashRaw) {
|
||||
hashRaw = splitPrefix(rest, '-');
|
||||
hashRaw = splitPrefixTo(rest, '-');
|
||||
if (hashRaw)
|
||||
isSRI = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue