diff options
-rw-r--r-- | libbpkg/manifest.cxx | 4 | ||||
-rw-r--r-- | libbpkg/manifest.hxx | 26 | ||||
-rw-r--r-- | tests/repository-location/driver.cxx | 5 |
3 files changed, 21 insertions, 14 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index 306649d..6a5ff23 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -2160,10 +2160,10 @@ namespace bpkg { static const char* invalid_location ("invalid repository location"); - if (l.local () || l.type () != repository_type::bpkg) + if (l.local ()) throw invalid_argument (invalid_location); - if (!url || (*url)[0] != '.') + if (l.type () != repository_type::bpkg || !url || (*url)[0] != '.') return url; const path rp (*url); diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index 743df48..905eea1 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -376,7 +376,8 @@ namespace bpkg std::vector<requirement_alternatives> requirements; std::vector<build_constraint> build_constraints; - // The following values are only valid in the manifest list. + // The following values are only valid in the manifest list (and only for + // certain repository types). // butl::optional<butl::path> location; butl::optional<std::string> sha256sum; @@ -473,9 +474,9 @@ namespace bpkg // // - For the local URL object the path can be relative or absolute. Query // can not be present. Fragment can not be present for the relative path - // as there is no notation that can be used to represent it. The file:// - // notation can be enforced for the absolute path by setting the authority - // to an empty object. + // as there is no notation that can be used to represent it. Represent + // the object as a local path if it is absolute and there is no fragment or + // authority present. // struct LIBBPKG_EXPORT repository_url: butl::basic_url<repository_protocol, repository_url_traits> @@ -695,13 +696,14 @@ namespace bpkg public: using email_type = bpkg::email; - repository_location location; // bpkg repository location. + repository_location location; // Non-empy for non-base roles. butl::optional<repository_role> role; - // The following values may only be present for the base repository. + // The following values may only be present for the base repository (and + // only for certain repository types). // butl::optional<std::string> url; - butl::optional<email_type> email; + butl::optional<email_type> email; butl::optional<std::string> summary; butl::optional<std::string> description; butl::optional<std::string> certificate; @@ -719,11 +721,11 @@ namespace bpkg effective_role () const; // Return the effective web interface URL based on the specified remote - // bpkg repository location. If url is not present or doesn't start with - // '.', then return it unchanged. Otherwise, process the relative format - // as described in the manifest specification. Throw std::invalid_argument - // if the relative url format is invalid or if the repository location is - // empty or local. + // repository location. If url is not present, doesn't start with '.', or + // the repository type differs from bpkg, then return it unchanged. + // Otherwise, process the relative format as described in the manifest + // specification. Throw std::invalid_argument if the relative url format is + // invalid or if the repository location is empty or local. // butl::optional<std::string> effective_url (const repository_location&) const; diff --git a/tests/repository-location/driver.cxx b/tests/repository-location/driver.cxx index 862b801..18ccd2a 100644 --- a/tests/repository-location/driver.cxx +++ b/tests/repository-location/driver.cxx @@ -710,6 +710,11 @@ namespace bpkg "http://cppget.org/pkg/foo/misc/stable"); } { + repository_location l (loc ("https://git.github.com/test.git#master", + repository_type::git)); + assert (effective_url ("../..", l) == "../.."); + } + { repository_location l ( loc ("http://www.cppget.org/foo/bpkg/1/misc/stable")); |