From b0b833e6a7330b38bc2732d681a8f48c380d49e8 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 18 Jan 2018 23:55:47 +0300 Subject: Allow enforcing file:// notation for repository_url::string() --- libbpkg/manifest.cxx | 10 ++-------- libbpkg/manifest.hxx | 6 ++++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index 9859a47..306649d 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -1524,7 +1524,7 @@ namespace bpkg repository_url_traits::string_type repository_url_traits:: translate_scheme (string_type& url, const scheme_type& scheme, - const optional& /*authority*/, + const optional& authority, const optional& path, const optional& /*query*/, const optional& fragment) @@ -1536,16 +1536,10 @@ namespace bpkg case scheme_type::git: return "git"; case scheme_type::file: { - // If there is no fragment present then represent the URL object as a - // local path. - // assert (path); - if (fragment) - { - assert (path->absolute ()); + if (path->absolute () && (fragment || authority)) return "file"; - } url = path->relative () ? path->posix_string () : path->string (); return string_type (); diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index 7f5bcda..743df48 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -473,7 +473,9 @@ namespace bpkg // // - For the local URL object the path can be relative or absolute. Query // can not be present. Fragment can not be present for the relative path - // as there is no notation that can be used to represent it. + // as there is no notation that can be used to represent it. The file:// + // notation can be enforced for the absolute path by setting the authority + // to an empty object. // struct LIBBPKG_EXPORT repository_url: butl::basic_url @@ -598,7 +600,7 @@ namespace bpkg // URL of an empty location is empty. // - repository_url + const repository_url& url () const { return url_; -- cgit v1.1