fix: asset protocol CORS on Windows
@@ -304,7 +304,11 @@ impl<R: Runtime> WindowManager<R> {
}
if !registered_scheme_protocols.contains(&"asset".into()) {
let window_url = Url::parse(&pending.url).unwrap();
- let window_origin = format!(
+ let window_origin =
+ if cfg!(windows) && window_url.scheme() != "http" && window_url.scheme() != "https" {
+ format!("https://{}.localhost", window_url.scheme())
+ } else {
+ format!(
"{}://{}{}",
window_url.scheme(),
window_url.host().unwrap(),
@@ -313,7 +317,8 @@ impl<R: Runtime> WindowManager<R> {
} else {
"".into()
}
- );
+ )
+ };
pending.register_uri_scheme_protocol("asset", move |request| {
#[cfg(target_os = "windows")]
let path = request.uri().replace("asset://localhost/", "");
