You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The constructors on Uri that take a string have the following usage requirements:
/// If the `uri` input
/// string doesn't not represent a valid URI, this object is left in an
/// invalid state (isValid() will return false).
This is an easy footgun, as a URI parse failure is silent and requires the user to verify the validity of the Uri after construction. A better interface would make the fallibility of parsing a URI more directly addressable. Therefore, I propose a new interface to Uri:
classUri {
public:/// Parse the specified `uriString` into the specified `result` object/// if `uriString` is a valid URI, otherwise load the specified/// `errorDescription` with a description of the syntax error present in/// `uriString`. Return 0 on success and non-zero if `uriString` does/// not have a valid syntax. Note that `errorDescription` may be null/// if the caller does not care about getting error messages. The/// behavior is undefined unless `initialize` has been called/// previously.
BSLA_NODISCARD
staticintparse(Uri* result,
const bslstl::StringRef& uriString,
bsl::string* errorDescription);
};
This is basically the function UriParser::parse, except that interface requires the user to call UriParser::init(allocator) prior to use. The Uri::parse function will effectively do this:
The constructors on
Uri
that take a string have the following usage requirements:This is an easy footgun, as a URI parse failure is silent and requires the user to verify the validity of the
Uri
after construction. A better interface would make the fallibility of parsing a URI more directly addressable. Therefore, I propose a new interface toUri
:This is basically the function
UriParser::parse
, except that interface requires the user to callUriParser::init(allocator)
prior to use. TheUri::parse
function will effectively do this:The text was updated successfully, but these errors were encountered: