about summary refs log tree commit diff stats
path: root/src/utils/twtstr.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-01-27 01:38:23 +0100
committerbptato <nincsnevem662@gmail.com>2024-01-27 01:43:39 +0100
commitfb2f0b91ae59612495143982212f3def20d3bf68 (patch)
treeaa9cc8466b008237cad1e1d2d62a3702c93d989c /src/utils/twtstr.nim
parent1c0df44ae9d9ac498ff6335f044ff5294fd62441 (diff)
downloadchawan-fb2f0b91ae59612495143982212f3def20d3bf68.tar.gz
mimetypes: simplify parseMimeTypes
* use functions like until
* do not call atEnd for every line, use boolean readLine instead
Diffstat (limited to 'src/utils/twtstr.nim')
-rw-r--r--src/utils/twtstr.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index f1af1998..1584f3f5 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -205,6 +205,12 @@ func until*(s: string, c: set[char], starti = 0): string =
       break
     result.add(s[i])
 
+func untilLower*(s: string, c: set[char], starti = 0): string =
+  for i in starti ..< s.len:
+    if s[i] in c:
+      break
+    result.add(s[i].toLowerAscii())
+
 func until*(s: string, c: char, starti = 0): string =
   s.until({c}, starti)