aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-01-18 23:55:47 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-02-08 18:40:35 +0300
commitb0b833e6a7330b38bc2732d681a8f48c380d49e8 (patch)
treefded911558f11bb22900504597bcb2570d689243
parent25983f96f12870d3712e95a49a0cae606493c8b2 (diff)
Allow enforcing file:// notation for repository_url::string()
-rw-r--r--libbpkg/manifest.cxx10
-rw-r--r--libbpkg/manifest.hxx6
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_type>& /*authority*/,
+ const optional<authority_type>& authority,
const optional<path_type>& path,
const optional<string_type>& /*query*/,
const optional<string_type>& 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<repository_protocol,
repository_url_traits>
@@ -598,7 +600,7 @@ namespace bpkg
// URL of an empty location is empty.
//
- repository_url
+ const repository_url&
url () const
{
return url_;