diff options
author | Dzmitry Zaitsau <pradd.me@gmail.com> | 2019-02-21T10·44+0100 |
---|---|---|
committer | Dzmitry Zaitsau <pradd.me@gmail.com> | 2019-02-25T16·59+0100 |
commit | 07f992a74b64f4376d5b415d0042babc924772f3 (patch) | |
tree | 65b730daf2fd0920750ddb58ce853f96c24c2d11 /src/libstore/store-api.cc | |
parent | 6bfb082ea298ac4366d4808f3a1b7c065cf89302 (diff) |
Extract and expose splitUriAndParams function
which splits a URL into localtor and parameter parts
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 913a1112141e..c13ff11564ec 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -842,12 +842,11 @@ namespace nix { RegisterStoreImplementation::Implementations * RegisterStoreImplementation::implementations = 0; - -ref<Store> openStore(const std::string & uri_, - const Store::Params & extraParams) +/* Split URI into protocol+hierarchy part and its parameter set. */ +std::pair<std::string, Store::Params> splitUriAndParams(const std::string & uri_) { auto uri(uri_); - Store::Params params(extraParams); + Store::Params params; auto q = uri.find('?'); if (q != std::string::npos) { for (auto s : tokenizeString<Strings>(uri.substr(q + 1), "&")) { @@ -873,6 +872,15 @@ ref<Store> openStore(const std::string & uri_, } uri = uri_.substr(0, q); } + return {uri, params}; +} + +ref<Store> openStore(const std::string & uri_, + const Store::Params & extraParams) +{ + auto [uri, uriParams] = splitUriAndParams(uri_); + auto params = extraParams; + params.insert(uriParams.begin(), uriParams.end()); for (auto fun : *RegisterStoreImplementation::implementations) { auto store = fun(uri, params); |