aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-09-03 22:43:38 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-09-03 22:43:38 +0300
commit09702fc27c673066c87193879d2fdbc19ab9b33f (patch)
tree0313b87e8f7e77dd71b329c36f7c32979478344f
parent3986a17f6b461516a5c9a933b1ae3a79c692d0bf (diff)
Normalize host in repository URL
-rw-r--r--libbpkg/manifest.cxx7
-rw-r--r--libbpkg/manifest.hxx4
-rw-r--r--tests/repository-location/driver.cxx5
3 files changed, 9 insertions, 7 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx
index 7514357..016e88c 100644
--- a/libbpkg/manifest.cxx
+++ b/libbpkg/manifest.cxx
@@ -3153,12 +3153,9 @@ namespace bpkg
if (!authority || authority->host.empty ())
bad_url ("invalid host");
- // Normalize the host name.
+ // Normalize the host name/address.
//
- // @@ Also add IPv4/6 addresses normalization.
- //
- if (authority->host.kind == url_host_kind::name)
- lcase (authority->host.value);
+ authority->host.normalize ();
// We don't distinguish between the absent and empty paths for the
// remote repository URLs.
diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx
index dfb8762..b666716 100644
--- a/libbpkg/manifest.hxx
+++ b/libbpkg/manifest.hxx
@@ -1026,8 +1026,8 @@ namespace bpkg
// non-empty object with non-empty path never contains the trailing slash
// (except for the root path on POSIX system).
//
- // - For the remote URL object the host name is in the lower case (IPv4/6 are
- // not supported) and the path is relative.
+ // - For the remote URL object the host component is normalized (see
+ // butl::basic_url_host for details) and the path is relative.
//
// - For the local URL object the path can be relative or absolute. Query
// can not be present. Represent the object using the file:// notation if
diff --git a/tests/repository-location/driver.cxx b/tests/repository-location/driver.cxx
index a91c2e8..32f5b8e 100644
--- a/tests/repository-location/driver.cxx
+++ b/tests/repository-location/driver.cxx
@@ -562,6 +562,11 @@ namespace bpkg
assert (l.canonical_name () == "pkg:cppget.org/qw/a/b");
}
{
+ repository_location l (loc ("http://00.00.010.0/qw/1/a/b/"));
+ assert (l.string () == "http://0.0.10.0/qw/1/a/b");
+ assert (l.canonical_name () == "pkg:0.0.10.0/qw/a/b");
+ }
+ {
repository_location l (loc ("http://pkg.CPPget.org/qw/1/a/b/"));
assert (l.string () == "http://pkg.cppget.org/qw/1/a/b");
assert (l.canonical_name () == "pkg:cppget.org/qw/a/b");