diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-01-21 18:38:53 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-01-21 19:01:10 +0300 |
commit | d7dd0b4a865a8e60a8e308090fab548033fcd3da (patch) | |
tree | ba9cb67b851055081b04d77f02a1e10f7169bab0 | |
parent | f03c36bde6a43ad84ae412d46b3e466de82fab6e (diff) |
Fix url constructor to throw for invalid URL string representation
-rw-r--r-- | libbutl/url.mxx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libbutl/url.mxx b/libbutl/url.mxx index 5375698..585526a 100644 --- a/libbutl/url.mxx +++ b/libbutl/url.mxx @@ -87,7 +87,7 @@ LIBBUTL_MODEXPORT namespace butl // representations. // // Note also that we currently forbid one character schemes to support - // scheme- less (Windows) paths which can be done by + // scheme-less (Windows) paths which can be done by // url_traits::translate_scheme() (see below). (A Windows path that uses // forward slashes would be parsed as a valid authority-less URL). @@ -199,7 +199,9 @@ LIBBUTL_MODEXPORT namespace butl optional<string_type>& /*fragment*/, bool& /*rootless*/) { - return scheme_type (std::move (scheme)); + return !scheme.empty () + ? optional<scheme_type> (std::move (scheme)) + : nullopt; // Leave the URL object constructor to throw. } // Translate scheme type back to its string representation. |