Skip to content

Commit 4077aa4

Browse files
committed
ParsedURL: Remove base field
1 parent f705ce7 commit 4077aa4

File tree

6 files changed

+2
-20
lines changed

6 files changed

+2
-20
lines changed

src/libfetchers/git.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ struct GitInputScheme : InputScheme
426426
auto url = parseURL(getStrAttr(input.attrs, "url"));
427427
bool isBareRepository = url.scheme == "file" && !pathExists(url.path + "/.git");
428428
repoInfo.isLocal = url.scheme == "file" && !forceHttp && !isBareRepository;
429-
repoInfo.url = repoInfo.isLocal ? url.path : url.base;
429+
repoInfo.url = repoInfo.isLocal ? url.path : url.to_string();
430430

431431
// If this is a local directory and no ref or revision is
432432
// given, then allow the use of an unclean working tree.

src/libfetchers/mercurial.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ struct MercurialInputScheme : InputScheme
161161
{
162162
auto url = parseURL(getStrAttr(input.attrs, "url"));
163163
bool isLocal = url.scheme == "file";
164-
return {isLocal, isLocal ? url.path : url.base};
164+
return {isLocal, isLocal ? url.path : url.to_string()};
165165
}
166166

167167
StorePath fetchToStore(ref<Store> store, Input & input) const

src/libflake/flake/flakeref.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,7 @@ std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
159159

160160
while (flakeRoot != "/") {
161161
if (pathExists(flakeRoot + "/.git")) {
162-
auto base = std::string("git+file://") + flakeRoot;
163-
164162
auto parsedURL = ParsedURL{
165-
.base = base,
166163
.scheme = "git+file",
167164
.authority = "",
168165
.path = flakeRoot,
@@ -219,7 +216,6 @@ static std::optional<std::pair<FlakeRef, std::string>> parseFlakeIdRef(
219216

220217
if (std::regex_match(url, match, flakeRegex)) {
221218
auto parsedURL = ParsedURL{
222-
.base = "flake:" + match.str(1),
223219
.scheme = "flake",
224220
.authority = "",
225221
.path = match[1],

src/libutil-tests/url.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ namespace nix {
2525
auto parsed = parseURL(s);
2626

2727
ParsedURL expected {
28-
.base = "http://www.example.org/file.tar.gz",
2928
.scheme = "http",
3029
.authority = "www.example.org",
3130
.path = "/file.tar.gz",
@@ -41,7 +40,6 @@ namespace nix {
4140
auto parsed = parseURL(s);
4241

4342
ParsedURL expected {
44-
.base = "https://www.example.org/file.tar.gz",
4543
.scheme = "https",
4644
.authority = "www.example.org",
4745
.path = "/file.tar.gz",
@@ -57,7 +55,6 @@ namespace nix {
5755
auto parsed = parseURL(s);
5856

5957
ParsedURL expected {
60-
.base = "https://www.example.org/file.tar.gz",
6158
.scheme = "https",
6259
.authority = "www.example.org",
6360
.path = "/file.tar.gz",
@@ -73,7 +70,6 @@ namespace nix {
7370
auto parsed = parseURL(s);
7471

7572
ParsedURL expected {
76-
.base = "http://www.example.org/file.tar.gz",
7773
.scheme = "http",
7874
.authority = "www.example.org",
7975
.path = "/file.tar.gz",
@@ -89,7 +85,6 @@ namespace nix {
8985
auto parsed = parseURL(s);
9086

9187
ParsedURL expected {
92-
.base = "https://www.example.org/video.mp4",
9388
.scheme = "file+https",
9489
.authority = "www.example.org",
9590
.path = "/video.mp4",
@@ -110,7 +105,6 @@ namespace nix {
110105
auto parsed = parseURL(s);
111106

112107
ParsedURL expected {
113-
.base = "https://127.0.0.1:8080/file.tar.gz",
114108
.scheme = "http",
115109
.authority = "127.0.0.1:8080",
116110
.path = "/file.tar.gz",
@@ -126,7 +120,6 @@ namespace nix {
126120
auto parsed = parseURL(s);
127121

128122
ParsedURL expected {
129-
.base = "http://[fe80::818c:da4d:8975:415c\%enp0s25]:8080",
130123
.scheme = "http",
131124
.authority = "[fe80::818c:da4d:8975:415c\%enp0s25]:8080",
132125
.path = "",
@@ -143,7 +136,6 @@ namespace nix {
143136
auto parsed = parseURL(s);
144137

145138
ParsedURL expected {
146-
.base = "http://[2a02:8071:8192:c100:311d:192d:81ac:11ea]:8080",
147139
.scheme = "http",
148140
.authority = "[2a02:8071:8192:c100:311d:192d:81ac:11ea]:8080",
149141
.path = "",
@@ -166,7 +158,6 @@ namespace nix {
166158
auto parsed = parseURL(s);
167159

168160
ParsedURL expected {
169-
.base = "http://user:[email protected]/file.tar.gz",
170161
.scheme = "http",
171162
.authority = "user:[email protected]:8080",
172163
.path = "/file.tar.gz",
@@ -183,7 +174,6 @@ namespace nix {
183174
auto parsed = parseURL(s);
184175

185176
ParsedURL expected {
186-
.base = "",
187177
.scheme = "file",
188178
.authority = "",
189179
.path = "/none/of//your/business",
@@ -207,7 +197,6 @@ namespace nix {
207197
auto parsed = parseURL(s);
208198

209199
ParsedURL expected {
210-
.base = "ftp://ftp.nixos.org/downloads/nixos.iso",
211200
.scheme = "ftp",
212201
.authority = "ftp.nixos.org",
213202
.path = "/downloads/nixos.iso",

src/libutil/url.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ ParsedURL parseURL(const std::string & url)
4040
path = "/";
4141

4242
return ParsedURL{
43-
.base = base,
4443
.scheme = scheme,
4544
.authority = authority,
4645
.path = percentDecode(path),

src/libutil/url.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ namespace nix {
77

88
struct ParsedURL
99
{
10-
/// URL without query/fragment
11-
std::string base; // FIXME: remove
1210
std::string scheme;
1311
std::optional<std::string> authority;
1412
std::string path;

0 commit comments

Comments
 (0)