28 #include "../webview_impl.hpp"
30 static std::vector<std::string> split(
const std::string& input,
const std::string& regex)
34 std::sregex_token_iterator first{ input.begin(), input.end(), re, -1 };
35 std::sregex_token_iterator last;
36 return { first, last };
39 static std::map<std::string, std::string> urlsplit(
const std::string& url)
41 auto pos = url.find(
'?');
42 if (pos == std::string::npos)
44 auto surl = url.substr(pos);
45 auto args = split(surl,
"&");
47 std::map<std::string, std::string> argmap;
48 for (
const auto& arg : args)
50 auto kv = split(arg,
"=");
52 argmap.insert({ kv[0], kv[1] });
57 static void fkt(
const std::string& url,
void* arg)
59 auto args = urlsplit(url);
60 auto val = args.find(
"code");
61 if (val == args.end())
65 auto rcode =
static_cast<std::string*
>(arg);
69 bool webview_impl_run(
const std::string& title,
const std::string& url, std::string& code)
71 webview::webview w(
false,
nullptr);
74 w.set_size(640, 480, WEBVIEW_HINT_NONE);
77 w.add_scheme_handler(
"ms-appx-web", fkt, &scheme);
78 w.add_navigate_listener(fkt, &code);