Skip to content

Commit a58d84c

Browse files
committed
use relative path in html href
1 parent 16aba4f commit a58d84c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tw5server.nim

+4-4
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ proc sendDirContents(settings: NimHttpSettings, dir: string): NimHttpResponse =
113113
let subtitle = path.relativePath(cwd)
114114
for i in walkDir(path):
115115
let name = i.path.extractFilename
116-
let relpath = i.path.relativePath(cwd)
116+
let relpath = i.path.relativePath(path).strip(chars = {'/'}, trailing = false)
117117
if name == "index.html" or name == "index.htm":
118118
return sendStaticFile(settings, i.path)
119119
if i.path.dirExists:
@@ -136,7 +136,7 @@ proc logmsg(msg: string, log: bool) =
136136
if log:
137137
echo msg
138138

139-
proc getPut(req: Request, path, backup: string, log: bool): NimHttpResponse =
139+
proc getPut(req: Request, path, backup: string, log: bool): NimHttpResponse =
140140
let content = req.body
141141
writeFile(path, content)
142142
logmsg("Update: " & path, log)
@@ -171,7 +171,7 @@ proc savePost(req: Request, path, url_path: string, log: bool): NimHttpResponse
171171

172172
writeFile(path / newName, file_body)
173173
let
174-
rsp_msg = "Save file to " & newName
174+
rsp_msg = "Save file to " & newName
175175
msg = rsp_msg & " in " & path
176176
rsp_content = rsp_msg
177177
code = Http200
@@ -314,7 +314,7 @@ echo(" Backup dir: ", backup)
314314
proc handleCtrlC() {.noconv.} =
315315
write(stdout, "\rClean backups (y to clean): ")
316316
let clean = readLine(stdin)
317-
317+
318318
var cleaned = 0
319319
if "y" == clean:
320320
cleaned = clean_backup(dir, backup)

0 commit comments

Comments
 (0)