From 78229192fc54ec1822bb29146f08386e3c60f813 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 8 Mar 2018 18:14:44 +0300 Subject: Fix repository_name() to always recognize names for local repositories --- bpkg/manifest-utility.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'bpkg/manifest-utility.cxx') diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx index a2b817d..50ee4e8 100644 --- a/bpkg/manifest-utility.cxx +++ b/bpkg/manifest-utility.cxx @@ -155,19 +155,25 @@ namespace bpkg { size_t p (s.find (':')); - // If it has no scheme or the scheme looks like that of a URL, then this - // is not a canonical name. + // If it has no scheme, then this is not a canonical name. // - if (p == string::npos || butl::url::traits::find (s, p) != string::npos) + if (p == string::npos) return false; // This is a canonical name if the scheme is convertible to the repository - // type. + // type and is followed by the colon and no more than one slash. + // + // Note that the approach is valid unless we invent the file scheme for the + // canonical name. // try { - to_repository_type (string (s, 0, p)); - return true; + string scheme (s, 0, p); + to_repository_type (scheme); + bool r (!(p + 2 < s.size () && s[p + 1] == '/' && s[p + 2] == '/')); + + assert (!r || scheme != "file"); + return r; } catch (const invalid_argument&) { -- cgit v1.1