diff options
| -rw-r--r-- | adapter/protocol/gemini.nim | 2 | ||||
| -rw-r--r-- | src/main.nim | 2 | ||||
| -rw-r--r-- | src/types/cookie.nim | 2 | ||||
| -rw-r--r-- | src/utils/twtstr.nim | 4 | ||||
| -rw-r--r-- | test/net/run.nim | 2 |
5 files changed, 6 insertions, 6 deletions
diff --git a/adapter/protocol/gemini.nim b/adapter/protocol/gemini.nim index 0dcefd08..14ebce92 100644 --- a/adapter/protocol/gemini.nim +++ b/adapter/protocol/gemini.nim @@ -19,7 +19,7 @@ proc openKnownHosts(os: PosixStream): (File, string) = if ourDir == "": os.die("InternalError", "config dir missing") path = ourDir & '/' & "gemini_known_hosts" - createDir(path.beforeLast('/')) + createDir(path.untilLast('/')) let f = cast[File](fopen(cstring(path), "a+")) if f == nil: os.die("InternalError", "error opening open known hosts file") diff --git a/src/main.nim b/src/main.nim index 17d49870..c183c01f 100644 --- a/src/main.nim +++ b/src/main.nim @@ -227,7 +227,7 @@ proc initConfig(ctx: ParamParseContext; config: Config; const libexecPath {.strdefine.} = "$CHA_BIN_DIR/../libexec/chawan" proc main() = - putEnv("CHA_BIN_DIR", getAppFileName().beforeLast('/')) + putEnv("CHA_BIN_DIR", getAppFileName().untilLast('/')) putEnv("CHA_LIBEXEC_DIR", ChaPath(libexecPath).unquoteGet()) let forkserver = newForkServer() let urandom = newPosixStream("/dev/urandom", O_RDONLY, 0) diff --git a/src/types/cookie.nim b/src/types/cookie.nim index 305af9fa..60355995 100644 --- a/src/types/cookie.nim +++ b/src/types/cookie.nim @@ -125,7 +125,7 @@ proc `$`*(cookiejar: CookieJar): string = # https://www.rfc-editor.org/rfc/rfc6265#section-5.1.4 func defaultCookiePath(url: URL): string = - let path = url.pathname.beforeLast('/') + let path = url.pathname.untilLast('/') if path == "" or path[0] != '/': return "/" return path diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index dd9d0871..9cb7e8e2 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -286,7 +286,7 @@ func afterLast*(s: string; c: set[char]; n = 1): string = func afterLast*(s: string; c: char; n = 1): string = s.afterLast({c}, n) -func beforeLast*(s: string; c: set[char]; n = 1): string = +func untilLast*(s: string; c: set[char]; n = 1): string = var j = 0 for i in countdown(s.high, 0): if s[i] in c: @@ -295,7 +295,7 @@ func beforeLast*(s: string; c: set[char]; n = 1): string = return s.substr(0, i) return s -func beforeLast*(s: string; c: char; n = 1): string = s.beforeLast({c}, n) +func untilLast*(s: string; c: char; n = 1): string = s.untilLast({c}, n) proc c_sprintf(buf, fm: cstring): cint {.header: "<stdio.h>", importc: "sprintf", varargs} diff --git a/test/net/run.nim b/test/net/run.nim index d27bbef3..a88c9501 100644 --- a/test/net/run.nim +++ b/test/net/run.nim @@ -33,7 +33,7 @@ proc main() {.async.} = let port = server.getPort() case fork() of 0: - let cmd = getAppFileName().beforeLast('/') & "/run.sh " & $uint16(port) + let cmd = getAppFileName().untilLast('/') & "/run.sh " & $uint16(port) discard execl("/bin/sh", "sh", "-c", cstring(cmd), nil) quit(1) of -1: |