diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-03-08 18:14:44 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-03-09 14:54:52 +0300 |
commit | 78229192fc54ec1822bb29146f08386e3c60f813 (patch) | |
tree | 4e994888280268b33daea557903c2510a0a39905 /bpkg | |
parent | bf7f63e56640fa7756ebaacac36fcf23ce61afa3 (diff) |
Fix repository_name() to always recognize names for local repositories
Diffstat (limited to 'bpkg')
-rw-r--r-- | bpkg/manifest-utility.cxx | 18 |
1 files changed, 12 insertions, 6 deletions
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&) { |