Started work on drag dropping URL images
This commit is contained in:
parent
f972fd5024
commit
32a654b731
5 changed files with 75 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "StringHelpers.hpp"
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <regex>
|
||||
|
||||
std::vector<std::string> split_string_by_token(std::string str, std::string token) {
|
||||
// slightly modified from: https://stackoverflow.com/a/46943631
|
||||
|
|
@ -66,3 +67,13 @@ std::string read_file_to_string(const std::filesystem::path& filePath) {
|
|||
|
||||
return toRet;
|
||||
}
|
||||
|
||||
bool is_valid_http_url(const std::string& str) {
|
||||
if(str.empty())
|
||||
return false;
|
||||
|
||||
// Regex to check valid URL (from https://stackoverflow.com/a/3809435)
|
||||
std::regex pattern(R"rawstr(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))rawstr");
|
||||
|
||||
return std::regex_match(str, pattern);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue