Skip to content

Commit

Permalink
fix: check content-type before applying spa patch (closes jackyzha0#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed Nov 17, 2023
1 parent ea08c05 commit 3f0be7f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion quartz/components/scripts/spa.inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ let p: DOMParser
async function navigate(url: URL, isBack: boolean = false) {
p = p || new DOMParser()
const contents = await fetch(`${url}`)
.then((res) => res.text())
.then((res) => {
const contentType = res.headers.get("content-type")
if (contentType?.startsWith("text/html")) {
return res.text()
} else {
window.location.assign(url)
}
})
.catch(() => {
window.location.assign(url)
})
Expand Down

0 comments on commit 3f0be7f

Please sign in to comment.