@@ -102,8 +102,8 @@ std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
102102
103103 if (baseDir) {
104104 /* Check if 'url' is a path (either absolute or relative
105- to 'baseDir'). If so, search upward to the root of the
106- repo (i.e. the directory containing .git). */
105+ to 'baseDir'). If so, search upward to the root of the
106+ repo (i.e. the directory containing .git). */
107107
108108 path = absPath (path, baseDir);
109109
@@ -178,7 +178,7 @@ std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
178178 }
179179
180180 } else {
181- if (!hasPrefix (path, " / " ))
181+ if (!isAbsolute (path))
182182 throw BadURL (" flake reference '%s' is not an absolute path" , url);
183183 path = canonPath (path + " /" + getOr (query, " dir" , " " ));
184184 }
@@ -232,7 +232,12 @@ std::optional<std::pair<FlakeRef, std::string>> parseURLFlakeRef(
232232)
233233{
234234 try {
235- return fromParsedURL (fetchSettings, parseURL (url), isFlake);
235+ auto parsed = parseURL (url);
236+ if (baseDir
237+ && (parsed.scheme == " path" || parsed.scheme == " git+file" )
238+ && !isAbsolute (parsed.path ))
239+ parsed.path = absPath (parsed.path , *baseDir);
240+ return fromParsedURL (fetchSettings, std::move (parsed), isFlake);
236241 } catch (BadURL &) {
237242 return std::nullopt ;
238243 }
0 commit comments