MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Samples / GetLocalUri

Method GetLocalUri

SampleApps/WebView2APISample/AppWindow.cpp:2871–2891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2869}
2870
2871std::wstring AppWindow::GetLocalUri(
2872 std::wstring relativePath, bool useVirtualHostName /*= true*/)
2873{
2874 if (useVirtualHostName && m_webView3)
2875 {
2876 //! [LocalUrlUsage]
2877 const std::wstring localFileRootUrl = L"https://appassets.example/";
2878 return localFileRootUrl + regex_replace(relativePath, std::wregex(L"\\\\"), L"/");
2879 //! [LocalUrlUsage]
2880 }
2881 else
2882 {
2883 std::wstring path = GetLocalPath(L"assets\\" + relativePath, false);
2884 wil::com_ptr<IUri> uri;
2885 CHECK_FAILURE(CreateUri(path.c_str(), Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, 0, &uri));
2886
2887 wil::unique_bstr uriBstr;
2888 CHECK_FAILURE(uri->GetAbsoluteUri(&uriBstr));
2889 return std::wstring(uriBstr.get());
2890 }
2891}
2892
2893void AppWindow::RunAsync(std::function<void()> callback)
2894{

Calls

no outgoing calls

Tested by

no test coverage detected