diff options
author | bptato <nincsnevem662@gmail.com> | 2023-06-25 03:05:28 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-06-25 03:08:31 +0200 |
commit | 0461bbf6157fa4cfbc2c8054dc2c91d3593cad55 (patch) | |
tree | 5f9626b68ab74b0c3fdc18f00622ac9380f0d9fa /src/utils/twtstr.nim | |
parent | 4fb20b0d4edec5871c3c41e6e9da30df067b07ff (diff) | |
download | chawan-0461bbf6157fa4cfbc2c8054dc2c91d3593cad55.tar.gz |
Improve broken cookie handling, add multipart to form
Now it's not as horribly broken as before (but it's still far from perfect). We can at least log in to sr.ht (hooray). The form multipart part is straightforward, just pass what we used to pass long ago before I broke multipart.
Diffstat (limited to 'src/utils/twtstr.nim')
-rw-r--r-- | src/utils/twtstr.nim | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index 6d3c6f08..a9437a35 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -259,6 +259,17 @@ 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 = + var j = 0 + for i in countdown(s.high, 0): + if s[i] in c: + inc j + if j == n: + return s.substr(0, i) + return s + +func beforeLast*(s: string, c: char, n = 1): string = s.afterLast({c}, n) + proc c_sprintf(buf, fm: cstring): cint {.header: "<stdio.h>", importc: "sprintf", varargs} # From w3m |