浏览代码

fix(core): properly add CSP header to fallback routes (#3641)

Lucas Fernandes Nogueira 3 年之前
父节点
当前提交
bcd43168a5
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 5 0
      .changes/fix-csp-fallback-route.md
  2. 1 1
      core/tauri/src/manager.rs

+ 5 - 0
.changes/fix-csp-fallback-route.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Properly apply the CSP when loading a route that fallbacks to index.html.

+ 1 - 1
core/tauri/src/manager.rs

@@ -733,7 +733,6 @@ impl<R: Runtime> WindowManager<R> {
       // skip leading `/`
       path.chars().skip(1).collect::<String>()
     };
-    let is_html = path.ends_with(".html");
 
     let mut asset_path = AssetKey::from(path.as_str());
 
@@ -757,6 +756,7 @@ impl<R: Runtime> WindowManager<R> {
       .map(Cow::into_owned);
 
     let mut csp_header = None;
+    let is_html = asset_path.as_ref().ends_with(".html");
 
     match asset_response {
       Ok(asset) => {