all repos — nimhttpd @ 47e8c75582e18074fbb77486388d7993a5b6c0a0

A useful static file web server.

Fixed problem when serving parent directories.
h3rald h3rald@h3rald.com
Sun, 24 Mar 2024 17:29:29 +0100
commit

47e8c75582e18074fbb77486388d7993a5b6c0a0

parent

91fc711402f09721e68ebdfb5f55ee24154edde6

2 files changed, 6 insertions(+), 3 deletions(-)

jump to
M buildbuild

@@ -1,1 +1,1 @@

-nimble build -d:release --gc:orc --opt:size --verbose +nimble build -d:release --mm:orc --opt:size --verbose
M src/nimhttpd.nimsrc/nimhttpd.nim

@@ -87,10 +87,13 @@ """ % [title, style, subtitle, content, footer]

proc relativePath(path, cwd: string): string = var path2 = path - if cwd == "/": + var cwd2 = cwd + if cwd[^1] == '/' or cwd[^1] == '\\': + cwd2 = cwd[0..^2] + if cwd2 == "/": return path else: - path2.delete(0..cwd.len-1) + path2.delete(0..cwd2.len-1) var relpath = path2.replace("\\", "/") if (not relpath.endsWith("/")) and (not path.fileExists): relpath = relpath&"/"