From f83acbbfe389c356ce95f61c48d193961717c480 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 2 Feb 2020 16:02:54 +0100 Subject: [PATCH] Don't store fragment in FlakeRef --- src/libexpr/flake/flakeref.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libexpr/flake/flakeref.cc b/src/libexpr/flake/flakeref.cc index 5fc462246..a34d766d7 100644 --- a/src/libexpr/flake/flakeref.cc +++ b/src/libexpr/flake/flakeref.cc @@ -90,12 +90,11 @@ std::pair parseFlakeRefWithFragment( .scheme = "flake", .authority = "", .path = match[1], - .fragment = percentDecode(std::string(match[6])) }; return std::make_pair( FlakeRef(inputFromURL(parsedURL), ""), - parsedURL.fragment); + percentDecode(std::string(match[6]))); } /* Check if 'url' is a path (either absolute or relative to @@ -131,9 +130,10 @@ std::pair parseFlakeRefWithFragment( .authority = "", .path = flakeRoot, .query = decodeQuery(match[2]), - .fragment = percentDecode(std::string(match[3])) }; + auto fragment = percentDecode(std::string(match[3])); + if (subdir != "") { if (parsedURL.query.count("subdir")) throw Error("flake URL '%s' has an inconsistent 'subdir' parameter", url); @@ -142,14 +142,16 @@ std::pair parseFlakeRefWithFragment( return std::make_pair( FlakeRef(inputFromURL(parsedURL), get(parsedURL.query, "subdir").value_or("")), - parsedURL.fragment); + fragment); } else { auto parsedURL = parseURL(url); + std::string fragment; + std::swap(fragment, parsedURL.fragment); return std::make_pair( FlakeRef(inputFromURL(parsedURL), get(parsedURL.query, "subdir").value_or("")), - parsedURL.fragment); + fragment); } }