From f27e01c849a88803614f521f601efecca1da649c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 22 Feb 2018 17:35:20 +0300 Subject: Add repository URL fragment to canonical name --- libbpkg/manifest.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'libbpkg') diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index d58b6d8..8683037 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -11,7 +11,7 @@ #include // strncmp(), strcmp() #include // move() #include // uint16_t, UINT16_MAX -#include // find(), find_if_not(), replace() +#include // find(), find_if_not(), find_first_of(), replace() #include // invalid_argument #include @@ -2016,11 +2016,13 @@ namespace bpkg url_ = move (u); // Set canonical name to the base location canonical name 'bpkg:' - // part. The path part of the canonical name is calculated below. + // part. The '[#]' part of the canonical name is + // calculated below. // if (b.remote ()) canonical_name_ = - b.canonical_name_.substr (0, b.canonical_name_.find ("/")); + b.canonical_name_.substr (0, + b.canonical_name_.find_first_of ("/#")); } } @@ -2088,7 +2090,7 @@ namespace bpkg string cp (sp.relative () ? sp.posix_string () : sp.string ()); - // Don't allow empty canonical names. + // Don't allow canonical names without both host and path parts. // if (canonical_name_.empty () && cp.empty ()) throw invalid_argument ("empty repository name"); @@ -2107,6 +2109,12 @@ namespace bpkg } canonical_name_ += cp; + + if (url_.fragment) + { + canonical_name_ += '#'; + canonical_name_ += *url_.fragment; + } } // git_reference -- cgit v1.1