diff options
author | Yorick van Pelt <yorick@yorickvanpelt.nl> | 2023-02-07 16:45:01 +0100 |
---|---|---|
committer | Yorick van Pelt <yorick@yorickvanpelt.nl> | 2023-02-27 15:30:04 +0100 |
commit | 2c0866fc3f4583c178617f764cd1fa423737a14e (patch) | |
tree | f19bd6d9eb9ceb12d083fb3c043b2bfe389adb35 /src/libexpr/primops | |
parent | 0844856c8487e2bdf66a2272622f6bbf6b8b5fb8 (diff) |
fetchTree: convert fs path to url via ParsedURL::to_string
Diffstat (limited to 'src/libexpr/primops')
-rw-r--r-- | src/libexpr/primops/fetchTree.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libexpr/primops/fetchTree.cc b/src/libexpr/primops/fetchTree.cc index 2e924c302..c9faf3ffb 100644 --- a/src/libexpr/primops/fetchTree.cc +++ b/src/libexpr/primops/fetchTree.cc @@ -4,6 +4,7 @@ #include "fetchers.hh" #include "filetransfer.hh" #include "registry.hh" +#include "url.hh" #include <ctime> #include <iomanip> @@ -68,7 +69,16 @@ void emitTreeAttrs( std::string fixURI(std::string uri, EvalState & state, const std::string & defaultScheme = "file") { 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) |