about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-10-01 00:34:17 +0200
committerbptato <nincsnevem662@gmail.com>2023-10-01 00:34:17 +0200
commitf1814211abadd994cdf20e50a9e50fcf122acf85 (patch)
tree7f578cdaa0d853f68107a10f3f5869c0b63601e7 /src
parentc8a0af47b7fd8a38ba92554a9f342b03c66b2daa (diff)
downloadchawan-f1814211abadd994cdf20e50a9e50fcf122acf85.tar.gz
Get rid of unicode.toLower
It was used by mistake in a hundred percent of the cases we were
using it.
Diffstat (limited to 'src')
-rw-r--r--src/css/selectorparser.nim2
-rw-r--r--src/css/values.nim7
-rw-r--r--src/html/dom.nim6
-rw-r--r--src/types/cookie.nim4
-rw-r--r--src/types/url.nim2
5 files changed, 11 insertions, 10 deletions
diff --git a/src/css/selectorparser.nim b/src/css/selectorparser.nim
index c8144ffb..4dd08a89 100644
--- a/src/css/selectorparser.nim
+++ b/src/css/selectorparser.nim
@@ -91,7 +91,7 @@ proc add*(sels: var CompoundSelector, sel: Selector) {.inline.} =
 
 # For debugging
 func tostr(ftype: enum): string =
-  return ($ftype).split('_')[1..^1].join("-").tolower()
+  return ($ftype).split('_')[1..^1].join("-").toLowerAscii()
 
 func `$`*(cxsel: ComplexSelector): string
 
diff --git a/src/css/values.nim b/src/css/values.nim
index aa9feba0..1fe63ed4 100644
--- a/src/css/values.nim
+++ b/src/css/values.nim
@@ -351,7 +351,8 @@ func valueType(prop: CSSPropertyType): CSSValueType =
 func `$`*(length: CSSLength): string =
   if length.auto:
     return "auto"
-  return $length.num & ($length.unit).split('_')[1..^1].join("_").tolower()
+  let us = ($length.unit).split('_')[1..^1].join('_').toLowerAscii()
+  return $length.num & us
 
 func `$`*(content: CSSContent): string =
   if content.s != "":
@@ -372,14 +373,14 @@ func `$`*(val: CSSComputedValue): string =
 macro `{}`*(vals: CSSComputedValues, s: string): untyped =
   let t = propertyType($s)
   let vs = $valueType(t)
-  let s = vs.split('_')[1..^1].join("_").tolower()
+  let s = vs.split('_')[1..^1].join('_').toLowerAscii()
   result = newDotExpr(newTree(nnkBracketExpr, vals, newLit(t)), newIdentNode(s))
 
 macro `{}=`*(vals: CSSComputedValues, s: string, val: typed) =
   let t = propertyType($s)
   let v = valueType(t)
   let vs = $v
-  let s = vs.split('_')[1..^1].join("_").tolower()
+  let s = vs.split('_')[1..^1].join('_').toLowerAscii()
   let id = ident(s)
   let expr = newTree(nnkBracketExpr, vals, newLit(t))
   result = quote do:
diff --git a/src/html/dom.nim b/src/html/dom.nim
index eec535ad..9880f70d 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -809,7 +809,7 @@ proc attr*(element: Element, name, value: string)
 func baseURL*(document: Document): URL
 
 proc tostr(ftype: enum): string =
-  return ($ftype).split('_')[1..^1].join("-").tolower()
+  return ($ftype).split('_')[1..^1].join("-").toLowerAscii()
 
 func escapeText(s: string, attribute_mode = false): string =
   var nbsp_mode = false
@@ -1801,7 +1801,7 @@ func action*(element: Element): string =
 func enctype*(element: Element): FormEncodingType =
   if element.isSubmitButton():
     if element.attrb("formenctype"):
-      return case element.attr("formenctype").tolower()
+      return case element.attr("formenctype").toLowerAscii()
       of "application/x-www-form-urlencoded": FORM_ENCODING_TYPE_URLENCODED
       of "multipart/form-data": FORM_ENCODING_TYPE_MULTIPART
       of "text/plain": FORM_ENCODING_TYPE_TEXT_PLAIN
@@ -1811,7 +1811,7 @@ func enctype*(element: Element): FormEncodingType =
     let element = HTMLInputElement(element)
     if element.form != nil:
       if element.form.attrb("enctype"):
-        return case element.attr("enctype").tolower()
+        return case element.attr("enctype").toLowerAscii()
         of "application/x-www-form-urlencoded": FORM_ENCODING_TYPE_URLENCODED
         of "multipart/form-data": FORM_ENCODING_TYPE_MULTIPART
         of "text/plain": FORM_ENCODING_TYPE_TEXT_PLAIN
diff --git a/src/types/cookie.nim b/src/types/cookie.nim
index 6d7ab79a..627975ab 100644
--- a/src/types/cookie.nim
+++ b/src/types/cookie.nim
@@ -75,7 +75,7 @@ proc parseCookieDate(val: string): Option[DateTime] =
     if not foundMonth:
       block monthBlock: # test for month
         if dateToken.len < 3: break monthBlock
-        case dateToken.substr(0, 2).toLower()
+        case dateToken.substr(0, 2).toLowerAscii()
         of "jan": month = 1
         of "feb": month = 2
         of "mar": month = 3
@@ -229,7 +229,7 @@ proc newCookie*(str: string, url: URL = nil): JSResult[Cookie]
       continue
     let key = part.substr(0, n - 1)
     let val = part.substr(n + 1)
-    case key.toLower()
+    case key.toLowerAscii()
     of "expires":
       let date = parseCookieDate(val)
       if date.issome:
diff --git a/src/types/url.nim b/src/types/url.nim
index ac83538e..1e05f016 100644
--- a/src/types/url.nim
+++ b/src/types/url.nim
@@ -271,7 +271,7 @@ func domainToAscii*(domain: string, bestrict = false): Option[string] =
       return none(string)
     return result
   else:
-    return domain.tolower().some
+    return some(domain.toLowerAscii())
 
 func parseHost(input: string, special: bool): Option[Host] =
   if input.len == 0: return