aboutsummaryrefslogtreecommitdiff
path: root/libbpkg
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-01-15 23:16:08 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-01-15 23:16:08 +0300
commit25983f96f12870d3712e95a49a0cae606493c8b2 (patch)
tree967f393c91647d47e1d900d7e829798316ee8276 /libbpkg
parent7e1f2eda6cef99b46a53e4deb0e44ede5c0e9476 (diff)
Add type prefix for repository canonical name
Diffstat (limited to 'libbpkg')
-rw-r--r--libbpkg/manifest.cxx28
1 files changed, 19 insertions, 9 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx
index bd50c84..9859a47 100644
--- a/libbpkg/manifest.cxx
+++ b/libbpkg/manifest.cxx
@@ -1791,7 +1791,9 @@ namespace bpkg
if (remote ())
{
- canonical_name_ = strip_domain (url_.authority->host, type_);
+ canonical_name_ = to_string (type_);
+ canonical_name_ += ':';
+ canonical_name_ += strip_domain (url_.authority->host, type_);
// For canonical name and for the HTTP protocol, treat a.com and
// a.com:80 as the same name. The same rule applies to the HTTPS (port
@@ -1827,7 +1829,7 @@ namespace bpkg
url_ = move (u);
- // Set canonical name to the base location canonical name host
+ // Set canonical name to the base location canonical name 'bpkg:<host>'
// part. The path part of the canonical name is calculated below.
//
if (b.remote ())
@@ -1897,17 +1899,25 @@ namespace bpkg
string cp (sp.relative () ? sp.posix_string () : sp.string ());
+ // Don't allow empty canonical names.
+ //
+ if (canonical_name_.empty () && cp.empty ())
+ throw invalid_argument ("empty repository name");
+
// Note: allow empty paths (e.g., http://stable.cppget.org/1/).
//
- if (!canonical_name_.empty () && !cp.empty ()) // If we have host and dir.
- canonical_name_ += '/';
+ if (!cp.empty ())
+ {
+ if (!canonical_name_.empty ()) // If we have host and dir.
+ canonical_name_ += '/';
+ else // If we have just dir.
+ {
+ canonical_name_ = to_string (type_);
+ canonical_name_ += ':';
+ }
+ }
canonical_name_ += cp;
-
- // But don't allow empty canonical names.
- //
- if (canonical_name_.empty ())
- throw invalid_argument ("empty repository name");
}
// repository_manifest