From 7c4bb940410c8f5ad59e1d21d5565364a9a0cd71 Mon Sep 17 00:00:00 2001 From: bptato Date: Mon, 20 May 2024 18:12:09 +0200 Subject: html: improve Request, derive Client from Window * make Client an instance of Window (for less special casing) * misc work on Request & fetch * improve origin comparison (opaque origins of same URLs are now considered the same) --- src/utils/twtstr.nim | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/utils/twtstr.nim') diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index c657d15b..3cbcfcd3 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -552,12 +552,12 @@ proc makeCRLF*(s: string): string = else: result &= s[i] -func strictParseEnum*[T: enum](s: string): Opt[T] = +func strictParseEnum*[T: enum](s: string): Option[T] = # cmp when len is small enough, otherwise hashmap when {T.low..T.high}.len <= 4: for e in T.low .. T.high: if $e == s: - return ok(e) + return some(e) else: const tab = (func(): Table[string, T] = result = initTable[string, T]() @@ -565,15 +565,15 @@ func strictParseEnum*[T: enum](s: string): Opt[T] = result[$e] = e )() if s in tab: - return ok(tab[s]) - return err() + return some(tab[s]) + return none(T) -func parseEnumNoCase*[T: enum](s: string): Opt[T] = +func parseEnumNoCase*[T: enum](s: string): Option[T] = # cmp when len is small enough, otherwise hashmap when {T.low..T.high}.len <= 4: for e in T.low .. T.high: if ($e).equalsIgnoreCase(s): - return ok(e) + return some(e) else: const tab = (func(): Table[string, T] = result = initTable[string, T]() @@ -581,8 +581,8 @@ func parseEnumNoCase*[T: enum](s: string): Opt[T] = result[$e] = e )() if s in tab: - return ok(tab[s]) - return err() + return some(tab[s]) + return none(T) proc getContentTypeAttr*(contentType, attrname: string): string = var i = contentType.find(';') -- cgit 1.4.1-2-gfad0