def url.bytes
gralha-http-core@0.1.0.0 · http.bend:124
import gralha-http-core@0.1.0.0/http.bend as Http
import Base
124def url.bytes(s: String, +acc: List<&2, U32>) -> List<&2, U32>:
125 match s:
126 case SNil{}:
127 List.reverse(&2, U32, acc)
128 case SCon{Chr{+c}, SCon{Chr{+x}, SCon{Chr{+y}, +t}}}:
129 when(List<&2, U32>, U32.is_eq(c, 37) && hex.is_digit(x) && hex.is_digit(y),
130 _ => url.bytes(t, (hex.digit(x) * 16 + hex.digit(y) : U32) <> acc),
131 _ => url.bytes(SCon{Chr{x}, SCon{Chr{y}, t}},
132 utf8.push(when(U32, U32.is_eq(c, 43), _ => 32, _ => c), acc)))
133 case SCon{Chr{+c}, t}:
134 url.bytes(t, utf8.push(when(U32, U32.is_eq(c, 43), _ => 32, _ => c), acc))