Patch files to prevent fetching urls even if file exists, adjust mime types for server

This commit is contained in:
DataHoarder 2022-02-20 03:55:40 +01:00
parent 719019d62d
commit 85bd2ff4da
2 changed files with 10 additions and 6 deletions

View file

@ -34,10 +34,6 @@ fetchFileURL() {
}
fetchFile () {
uri=$(fetchFileURL "${1}")
if [[ "${uri}" == "" ]]; then
return 1
fi
RESULT_PATH="${PAGE_PATH}${1}.${3}"
if [[ -f "${RESULT_PATH}" ]]; then
@ -47,7 +43,11 @@ fetchFile () {
fi
fi
echo "${uri}" >&2
uri=$(fetchFileURL "${1}")
if [[ "${uri}" == "" ]]; then
return 1
fi
doFullRequest "${uri}" > .files.tmp
if [[ $(isValidPageResult .files.tmp) == "yes" ]]; then
mv .files.tmp "${RESULT_PATH}"

View file

@ -1023,7 +1023,11 @@ func main() {
byteEntries, _ := json.Marshal(dirEntries)
writer.Write(byteEntries)
} else {
writer.Header().Set("Content-Type", "text/plain")
if path.Ext(filePath) == ".wiki" {
writer.Header().Set("Content-Type", "text/plain")
} else if path.Ext(filePath) == ".md" {
writer.Header().Set("Content-Type", "text/markdown")
}
http.ServeFile(writer, request, filePath)
}
}