diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-03 17:44:29 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-03 17:44:29 +0200 |
commit | b726efcfd9462255d1ff2eedb9e9cdcb9f85b8b2 (patch) | |
tree | 80c9b19eb9d8102809fecc48b8fd5afd1db3aadd /libbutl/url.mxx | |
parent | f46f33a29f55ed70ec4e5f45bafeca8e1b51dc76 (diff) |
Add url::traits::find(), checks whether string looks like URL
Diffstat (limited to 'libbutl/url.mxx')
-rw-r--r-- | libbutl/url.mxx | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libbutl/url.mxx b/libbutl/url.mxx index fe091f1..577434f 100644 --- a/libbutl/url.mxx +++ b/libbutl/url.mxx @@ -216,6 +216,17 @@ LIBBUTL_MODEXPORT namespace butl // static string_type translate_path (const path_type& path) {return string_type (path);} + + // Check whether a string looks like a URL by searching for the first ':' + // (unless its position is specified with the second argument) and then + // making sure it's followed by '/' (e.g., http:// or file:/) and preceded + // by the scheme at least 2 characters long (so we don't confuse it with + // an absolute Windows path, e.g., c:/). + // + // Return the start of the URL substring or string_type::npos. + // + static std::size_t + find (const string_type&, std::size_t pos = string_type::npos); }; template <typename H, // scheme |