diff options
author | bptato <nincsnevem662@gmail.com> | 2024-05-20 18:12:09 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-05-20 18:12:09 +0200 |
commit | 7c4bb940410c8f5ad59e1d21d5565364a9a0cd71 (patch) | |
tree | d46d682ce9d4f308232c961985d8411c2a70197c /src/utils/twtstr.nim | |
parent | 723613b0a02605dbf715d74c70b9ec29f1092c76 (diff) | |
download | chawan-7c4bb940410c8f5ad59e1d21d5565364a9a0cd71.tar.gz |
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)
Diffstat (limited to 'src/utils/twtstr.nim')
-rw-r--r-- | src/utils/twtstr.nim | 16 |
1 files changed, 8 insertions, 8 deletions
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(';') |