{"record":{"id":"a2b9d1ae25f1699a","repo":"tauri-apps/tauri","slug":"tauri-isolation-pattern-only-supports-relative-o-a2b9d1","errorCode":null,"errorMessage":"Tauri \"Isolation\" Pattern only supports relative or absolute (`/`) paths.","messagePattern":"Tauri \"Isolation\" Pattern only supports relative or absolute \\(`/`\\) paths\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-utils/src/html2.rs","lineNumber":152,"sourceCode":"///\n/// # Stability\n///\n/// This dependency [`dom_query`] for [`Document`] might receive updates in minor releases.\n#[cfg(feature = \"isolation\")]\npub fn inline_isolation(document: &Document, dir: &std::path::Path) {\n  let scripts = document.select(\"script[src]\");\n\n  for script in scripts.nodes() {\n    let src = match script.attr(\"src\") {\n      Some(s) => s.to_string(),\n      None => continue,\n    };\n\n    let mut path = std::path::PathBuf::from(src);\n    if path.has_root() {\n      path = path\n        .strip_prefix(\"/\")\n        .expect(\"Tauri \\\"Isolation\\\" Pattern only supports relative or absolute (`/`) paths.\")\n        .into();\n    }\n\n    let file = std::fs::read_to_string(dir.join(path)).expect(\"unable to find isolation file\");\n\n    script.set_text(file);\n    script.remove_attr(\"src\");\n  }\n}\n\n// TODO: Verify this, this is not found in the HTML spec, see https://github.com/tauri-apps/tauri/pull/14265#discussion_r2415396842\n/// Normalize line endings in script content to match what the browser uses for CSP hashing.\n///\n/// According to the HTML spec, browsers normalize:\n/// - `\\r\\n` → `\\n`\n/// - `\\r`   → `\\n`\npub fn normalize_script_for_csp(input: &[u8]) -> Vec<u8> {\n  let mut output = Vec::with_capacity(input.len());","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/tauri-apps/tauri/blob/56d19c39e457b528433dc546106cd0bff4066bc2/crates/tauri-utils/src/html2.rs#L134-L170","documentation":"Same Isolation Pattern inlining logic as html.rs, implemented in the alternate HTML processing module (html2.rs): script src paths are resolved against the dist directory and rooted paths are normalized by stripping '/'. The expect fires when strip_prefix(\"/\") fails, i.e. the path is rooted without starting with '/': Windows drive letters or UNC paths.","triggerScenarios":"Using the html2-based processing path with an isolation index.html containing <script src=\"C:\\path\\file.js\"> or a UNC (\\\\server\\share\\file.js) src on Windows; Unix-style '/file.js' works.","commonSituations":"Windows development machines and CI; absolute local paths committed into the isolation template.","solutions":["Use a src relative to the frontend dist directory.","Or use a URL-absolute path starting with a single '/'.","Remove any drive-letter or UNC path from script src attributes in the isolation HTML."],"exampleFix":"<!-- before -->\n<script src=\"D:\\build\\isolation.js\"></script>\n\n<!-- after -->\n<script src=\"/isolation.js\"></script>","handlingStrategy":"validation","validationCode":"fn is_supported_isolation_src(src: &str) -> bool {\n    let b = src.as_bytes();\n    !(src.starts_with(\"\\\\\\\\\") || (b.len() >= 2 && b[1] == b':'))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use relative or single-leading-slash src values in the isolation HTML.","Reject Windows absolute and UNC paths in code review of the isolation template."],"tags":["tauri","isolation-pattern","windows","path","html"],"backgroundTag":"windows-absolute-path-error","analyzedSha":"56d19c39e457b528433dc546106cd0bff4066bc2","analyzedAt":"2026-08-20T13:59:20.734Z","contentChangedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}