fetchTree: convert fs path to url via ParsedURL::to_string

This commit is contained in:
Yorick 2023-02-07 16:45:01 +01:00
parent 0844856c84
commit 2c0866fc3f
No known key found for this signature in database
GPG key ID: A36E70F9DC014A15

View file

@ -4,6 +4,7 @@
#include "fetchers.hh" #include "fetchers.hh"
#include "filetransfer.hh" #include "filetransfer.hh"
#include "registry.hh" #include "registry.hh"
#include "url.hh"
#include <ctime> #include <ctime>
#include <iomanip> #include <iomanip>
@ -68,7 +69,16 @@ void emitTreeAttrs(
std::string fixURI(std::string uri, EvalState & state, const std::string & defaultScheme = "file") std::string fixURI(std::string uri, EvalState & state, const std::string & defaultScheme = "file")
{ {
state.checkURI(uri); state.checkURI(uri);
return uri.find("://") != std::string::npos ? uri : defaultScheme + "://" + uri; if (uri.find("://") == std::string::npos) {
const auto p = ParsedURL {
.scheme = defaultScheme,
.authority = "",
.path = uri
};
return p.to_string();
} else {
return uri;
}
} }
std::string fixURIForGit(std::string uri, EvalState & state) std::string fixURIForGit(std::string uri, EvalState & state)