diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-02-24 18:21:39 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-02-26 17:50:24 +0300 |
commit | 4fcd32b536f3d29755b1fecc7e3f06be64f996ca (patch) | |
tree | 4aebf6eeb7ac4de316ddc91b92c264f252f86d44 /bpkg/manifest-utility.cxx | |
parent | 12a5375f25d6a7be5a5741c728a8f9b8168761a4 (diff) |
Add support for rep-list and rep-remove, update rep-add
Diffstat (limited to 'bpkg/manifest-utility.cxx')
-rw-r--r-- | bpkg/manifest-utility.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx index ed50298..1500cee 100644 --- a/bpkg/manifest-utility.cxx +++ b/bpkg/manifest-utility.cxx @@ -142,4 +142,30 @@ namespace bpkg assert (false); // Can't be here. return dir_path (); } + + bool + repository_name (const string& s) + { + size_t n (s.size ()); + size_t p (s.find (':')); + + // If it has no scheme or starts with the URL scheme (followed by ://) then + // this is not a canonical name. + // + if (p == string::npos || (p + 2 < n && s[p + 1] == '/' && s[p + 2] == '/')) + return false; + + // This is a canonical name if the scheme is convertible to the repository + // type. + // + try + { + to_repository_type (string (s, 0, p)); + return true; + } + catch (const invalid_argument&) + { + return false; + } + } } |