From b726efcfd9462255d1ff2eedb9e9cdcb9f85b8b2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 3 Mar 2018 17:44:29 +0200 Subject: Add url::traits::find(), checks whether string looks like URL --- libbutl/url.mxx | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libbutl/url.mxx') 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