Factor the prefix splitting in hash
This commit is contained in:
parent
77b51f4598
commit
a1f66d1d9e
|
@ -7,6 +7,7 @@
|
||||||
#include "args.hh"
|
#include "args.hh"
|
||||||
#include "hash.hh"
|
#include "hash.hh"
|
||||||
#include "archive.hh"
|
#include "archive.hh"
|
||||||
|
#include "parser.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
#include "istringstream_nocopy.hh"
|
#include "istringstream_nocopy.hh"
|
||||||
|
|
||||||
|
@ -144,17 +145,15 @@ Hash::Hash(std::string_view original, std::optional<HashType> optType)
|
||||||
// Parse the has type before the separater, if there was one.
|
// Parse the has type before the separater, if there was one.
|
||||||
std::optional<HashType> optParsedType;
|
std::optional<HashType> optParsedType;
|
||||||
{
|
{
|
||||||
auto sep = rest.find(':');
|
auto hashRaw = splitPrefix(rest, ':');
|
||||||
if (sep == std::string_view::npos) {
|
|
||||||
sep = rest.find('-');
|
if (!hashRaw) {
|
||||||
if (sep != std::string_view::npos)
|
hashRaw = splitPrefix(rest, '-');
|
||||||
|
if (hashRaw)
|
||||||
isSRI = true;
|
isSRI = true;
|
||||||
}
|
}
|
||||||
if (sep != std::string_view::npos) {
|
if (hashRaw)
|
||||||
auto hashRaw = rest.substr(0, sep);
|
optParsedType = parseHashType(*hashRaw);
|
||||||
optParsedType = parseHashType(hashRaw);
|
|
||||||
rest = rest.substr(sep + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Either the string or user must provide the type, if they both do they
|
// Either the string or user must provide the type, if they both do they
|
||||||
|
|
Loading…
Reference in a new issue