aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/tests
diff options
context:
space:
mode:
authorEric Wolf <ericwolf42@gmail.com>2023-01-20 10:31:26 +0100
committerEric Wolf <ericwolf42@gmail.com>2023-01-20 10:31:26 +0100
commit4d50995effdaf1d04453293d1afa56e9c8ce6f24 (patch)
tree8afdf6167ce762a3d62417b5855c5f99eb395e41 /src/libutil/tests
parentb911307d7ae12260f6ace7c7b1cfb5f1e92f894f (diff)
Fix url parsing for urls using `file+`
`file+https://example.org/test.mp4` should not be rejected with `unexpected authority`.
Diffstat (limited to 'src/libutil/tests')
-rw-r--r--src/libutil/tests/url.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libutil/tests/url.cc b/src/libutil/tests/url.cc
index c3b233797..e0c438b4d 100644
--- a/src/libutil/tests/url.cc
+++ b/src/libutil/tests/url.cc
@@ -99,6 +99,27 @@ namespace nix {
ASSERT_EQ(parsed, expected);
}
+ TEST(parseURL, parsesFilePlusHttpsUrl) {
+ auto s = "file+https://www.example.org/video.mp4";
+ auto parsed = parseURL(s);
+
+ ParsedURL expected {
+ .url = "file+https://www.example.org/video.mp4",
+ .base = "https://www.example.org/video.mp4",
+ .scheme = "file+https",
+ .authority = "www.example.org",
+ .path = "/video.mp4",
+ .query = (StringMap) { },
+ .fragment = "",
+ };
+
+ ASSERT_EQ(parsed, expected);
+ }
+
+ TEST(parseURL, rejectsAuthorityInUrlsWithFileTransportation) {
+ auto s = "file://www.example.org/video.mp4";
+ ASSERT_THROW(parseURL(s), Error);
+ }
TEST(parseURL, parseIPv4Address) {
auto s = "http://127.0.0.1:8080/file.tar.gz?download=fast&when=now#hello";