mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 16:26:18 +02:00
Move getParsedTypeAndSRI
to a more suitable location
Also mark it static
This commit is contained in:
parent
2f93d9f2ba
commit
a7cd7425d9
2 changed files with 21 additions and 21 deletions
|
@ -144,6 +144,27 @@ Hash Hash::parseSRI(std::string_view original) {
|
||||||
return Hash(rest, parsedType, true);
|
return Hash(rest, parsedType, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mutates the string to eliminate the prefixes when found
|
||||||
|
static std::pair<std::optional<HashType>, bool> getParsedTypeAndSRI(std::string_view & rest) {
|
||||||
|
bool isSRI = false;
|
||||||
|
|
||||||
|
// Parse the has type before the separater, if there was one.
|
||||||
|
std::optional<HashType> optParsedType;
|
||||||
|
{
|
||||||
|
auto hashRaw = splitPrefix(rest, ':');
|
||||||
|
|
||||||
|
if (!hashRaw) {
|
||||||
|
hashRaw = splitPrefix(rest, '-');
|
||||||
|
if (hashRaw)
|
||||||
|
isSRI = true;
|
||||||
|
}
|
||||||
|
if (hashRaw)
|
||||||
|
optParsedType = parseHashType(*hashRaw);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {optParsedType, isSRI};
|
||||||
|
}
|
||||||
|
|
||||||
Hash Hash::parseAnyPrefixed(std::string_view original)
|
Hash Hash::parseAnyPrefixed(std::string_view original)
|
||||||
{
|
{
|
||||||
auto rest = original;
|
auto rest = original;
|
||||||
|
|
|
@ -21,26 +21,5 @@ static inline std::optional<std::string_view> splitPrefix(std::string_view & str
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mutates the string to eliminate the prefixes when found
|
|
||||||
std::pair<std::optional<HashType>, bool> getParsedTypeAndSRI(std::string_view & rest) {
|
|
||||||
bool isSRI = false;
|
|
||||||
|
|
||||||
// Parse the has type before the separater, if there was one.
|
|
||||||
std::optional<HashType> optParsedType;
|
|
||||||
{
|
|
||||||
auto hashRaw = splitPrefix(rest, ':');
|
|
||||||
|
|
||||||
if (!hashRaw) {
|
|
||||||
hashRaw = splitPrefix(rest, '-');
|
|
||||||
if (hashRaw)
|
|
||||||
isSRI = true;
|
|
||||||
}
|
|
||||||
if (hashRaw)
|
|
||||||
optParsedType = parseHashType(*hashRaw);
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::make_pair(optParsedType, isSRI);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue