fix a path bug that shows up on windows

This commit is contained in:
William Bell committed 2024-10-19 02:56:48 +01:00
1 parent 0095015d7d
commit 83a18d0d74
3 files changed
+8 -3

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
{
"name": "http.ar",
"version": "1.1.6"
"version": "1.1.7"
}
+3 -2
View File
@@ -5,6 +5,7 @@ import "url.ar" as url
import "version" as version
import "renderTemplate" as renderTemplate
import "contentType" as contentType
import "path_to_filename" as *
let __initHeaders() = {"content-type": "text/html; charset=utf-8", "server": "http.ar/"+version.version+" Argon/"+ArgonVersion}
@@ -45,9 +46,9 @@ let handle(routes, conn, onErr) = do
let FILE = file.read(path)
response.headers["content-type"] = contentType.getter(path)
if (attachment) do
response.headers["content-disposition"] = "attachment; filename="+attachment
response.headers["content-disposition"] = "attachment; filename="+json.stringify(attachment)
else do
response.headers["content-disposition"] = "inline; filename="+json.stringify(path.split("/")[-1])
response.headers["content-disposition"] = "inline; filename="+json.stringify(path_to_filename(path))
let doRange = "range" in request.headers
let FileSize = FILE.size()
let size = FileSize
+4
View File
@@ -0,0 +1,4 @@
let path_to_filename(path) = do
if (platform.os == "windows") do
path = path.replace("\\", "/")
return path.split("/")[-1]