From 9653c35fb9a4398942ecb305835a95fbd87c433a Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 28 Jul 2024 20:50:51 +0200 Subject: buffer, pager, config: add meta-refresh + misc fixes * buffer, pager, config: add meta-refresh value, which makes it possible to follow http-equiv=refresh META tags. * config: clean up redundant format mode parser * timeout: accept varargs for params to pass on to functions * pager: add "options" dict to JS gotoURL * twtstr: remove redundant startsWithNoCase --- src/utils/twtstr.nim | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'src/utils/twtstr.nim') diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index 14e93bda..44c6ea3f 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -45,12 +45,17 @@ func snakeToKebabCase*(s: string): string = c = '-' func kebabToCamelCase*(s: string): string = - result = s + result = "" var flip = false - for c in result.mitems: - if flip: - c = c.toUpperAscii() - flip = c == '-' + for c in s: + if c == '-': + flip = true + else: + if flip: + result &= c.toUpperAscii() + else: + result &= c + flip = false func camelToKebabCase*(s: string): string = result = "" @@ -61,17 +66,6 @@ func camelToKebabCase*(s: string): string = else: result &= c -func startsWithNoCase*(s, prefix: string): bool = - if s.len < prefix.len: - return false - # prefix.len is always lower - var i = 0 - while true: - if i == prefix.len: return true - if s[i].toLowerAscii() != prefix[i].toLowerAscii(): - return false - inc i - func hexValue*(c: char): int = if c in AsciiDigit: return int(c) - int('0') @@ -114,9 +108,9 @@ func toHexLower*(u: uint16): string = func equalsIgnoreCase*(s1, s2: string): bool {.inline.} = return s1.cmpIgnoreCase(s2) == 0 -func startsWithIgnoreCase*(s1, s2: string): bool = +func startsWithIgnoreCase*(s1, s2: string; si = 0): bool = if s1.len < s2.len: return false - for i in 0 ..< s2.len: + for i in si ..< s2.len: if s1[i].toLowerAscii() != s2[i].toLowerAscii(): return false return true -- cgit 1.4.1-2-gfad0