diff options
Diffstat (limited to 'src/utils/twtstr.nim')
-rw-r--r-- | src/utils/twtstr.nim | 30 |
1 files changed, 12 insertions, 18 deletions
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 |