about summary refs log tree commit diff stats
path: root/src/types
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-11-20 17:20:41 +0100
committerbptato <nincsnevem662@gmail.com>2023-11-20 17:20:41 +0100
commit342a1a7f787fc260448842ee312cf29825f96ba6 (patch)
treee4e1d28e424e60da8b2618195c40442b79bd2ba8 /src/types
parentd20fc30e10aeecfb2ede7adc4547b9ae394565b9 (diff)
downloadchawan-342a1a7f787fc260448842ee312cf29825f96ba6.tar.gz
twtstr: remove tolower, isWhitespace
* tolower: strutils toLowerAscii is good enough for the cases where
  we need it. Also, it's easy to confuse with unicode toLower and
  vice versa.
* isWhitespace: in AsciiWhitespace is more idiomatic. Also has a
  naming collision with unicode toLower.
Diffstat (limited to 'src/types')
-rw-r--r--src/types/blob.nim3
-rw-r--r--src/types/urimethodmap.nim2
-rw-r--r--src/types/url.nim6
3 files changed, 6 insertions, 5 deletions
diff --git a/src/types/blob.nim b/src/types/blob.nim
index b6ef4adf..9ddca2b5 100644
--- a/src/types/blob.nim
+++ b/src/types/blob.nim
@@ -1,4 +1,5 @@
 import options
+import strutils
 
 import js/dict
 import js/fromjs
@@ -86,7 +87,7 @@ proc newWebFile(ctx: JSContext, fileBits: seq[string], fileName: string,
     for c in options.`type`:
       if c notin char(0x20)..char(0x7E):
         break ctype
-      file.ctype &= c.tolower()
+      file.ctype &= c.toLowerAscii()
   return file
 
 #TODO File, Blob constructors
diff --git a/src/types/urimethodmap.nim b/src/types/urimethodmap.nim
index 8453e554..283564a2 100644
--- a/src/types/urimethodmap.nim
+++ b/src/types/urimethodmap.nim
@@ -51,7 +51,7 @@ proc parseURIMethodMap*(this: var URIMethodMap, s: string) =
     var k = ""
     var i = 0
     while i < line.len and line[i] notin AsciiWhitespace + {':'}:
-      k &= line[i].tolower()
+      k &= line[i].toLowerAscii()
       inc i
     if i >= line.len or line[i] != ':':
       continue # invalid
diff --git a/src/types/url.nim b/src/types/url.nim
index 69a3a78e..e115d54c 100644
--- a/src/types/url.nim
+++ b/src/types/url.nim
@@ -232,7 +232,7 @@ func endsInNumber(input: string): bool =
   if parts.len == 0: return false
   var last = parts[^1]
   if last != "":
-    if last.len == 2 and last[0] in Digits and last[1].tolower() == 'x':
+    if last.len == 2 and last[0] in Digits and last[1].toLowerAscii() == 'x':
       last = last.substr(2)
     for c in last:
       if c notin Digits:
@@ -366,7 +366,7 @@ proc basicParseURL*(input: string, base = none(URL), url: URL = URL(),
     case state
     of SCHEME_START_STATE:
       if has and c.isAlphaAscii():
-        buffer &= c.tolower()
+        buffer &= c.toLowerAscii()
         state = SCHEME_STATE
       elif not override:
         state = NO_SCHEME_STATE
@@ -375,7 +375,7 @@ proc basicParseURL*(input: string, base = none(URL), url: URL = URL(),
         return none(URL)
     of SCHEME_STATE:
       if has and c in AsciiAlphaNumeric + {'+', '-', '.'}:
-        buffer &= c.tolower()
+        buffer &= c.toLowerAscii()
       elif has and c == ':':
         if override:
           if url.scheme in SpecialSchemes and buffer notin SpecialSchemes: