url.bend checks
raw source on the hub · import bend-net-url@0.4.0.0/url.bend as Url
URL parsing, resolution, and percent-encoding (RFC 3986).
1 import
import Base
Types
type Url source · line 6 · raw
Data
Url@path:String -> @query:Map<&2, String> -> Url
type Pd source · line 76 · raw
Data
Lit: plain bytes. Hi: after "%". Lo: after "%" and one hex digit. Bad: never decodes.
PdLitPd
PdHiPd
PdLo@hi:U32 -> Pd
PdBadPd
type Abs source · line 272 · raw
Data
target is the RFC 9112 §3.2.1 origin-form: path (never empty) and query, no fragment.
Abs@scheme:String -> @host:String -> @port:U32 -> @target:String -> Abs
type PQ source · line 461 · raw
Data
A path, its query, and whether a "?" was present at all.
PQ@path:String -> @q:String -> @has_q:Bool -> PQ
Definitions
def unreserved source · line 9 · raw
@+c:U32 -> Bool
def path_ok source · line 12 · raw
@+c:U32 -> Bool
def hexn source · line 15 · raw
@+n:U32 -> U32
def hexhi source · line 18 · raw
@+n:U32 -> U32
def hexlo source · line 21 · raw
@+n:U32 -> U32
def pct.enc.push source · line 24 · raw
@+c:U32 -> @acc:String -> @keep:Bool -> String
def pct.enc.path source · line 31 · raw
@s:String -> @acc:String -> String
def pct.enc.query source · line 38 · raw
@s:String -> @acc:String -> String
def pct.encode_path source · line 45 · raw
@s:String -> String
def pct.encode_q source · line 48 · raw
@s:String -> String
def unhex.H source · line 51 · raw
@c:U32 -> @hex:Bool -> Maybe<&2, U32>
def unhex.h source · line 58 · raw
@+c:U32 -> @lo:Bool -> Maybe<&2, U32>
def unhex.d source · line 65 · raw
@+c:U32 -> @dec:Bool -> @lo:Bool -> Maybe<&2, U32>
def unhex source · line 72 · raw
@+c:U32 -> Maybe<&2, U32>
def pct.lit source · line 82 · raw
@+c:U32 -> @racc:String -> @pct:Bool -> Pair(Pd, String)
def pct.hi source · line 89 · raw
@m:Maybe<&2, U32> -> @racc:String -> Pair(Pd, String)
def pct.lo source · line 96 · raw
@+x:U32 -> @m:Maybe<&2, U32> -> @racc:String -> Pair(Pd, String)
def pct.byte source · line 103 · raw
@h:Char -> U32
def pct.end source · line 107 · raw
@st:Pd -> @racc:String -> Maybe<&2, String>
def pct.step source · line 118 · raw
@st:Pd -> @+c:U32 -> @racc:String -> Pair(Pd, String)
def pct.end.of source · line 129 · raw
@sr:Pair(Pd, String) -> Maybe<&2, String>
def pct.step.of source · line 133 · raw
@sr:Pair(Pd, String) -> @+c:U32 -> Pair(Pd, String)
def pct.decode.go source · line 137 · raw
@s:String -> @sr:Pair(Pd, String) -> Maybe<&2, String>
def pct.decode source · line 144 · raw
@s:String -> Maybe<&2, String>
def take.cut source · line 148 · raw
@acc:String -> @rest:String -> Pair(String, String)
Bool.pick evaluates both arms; a split that recursed inside it would reverse acc at every byte.
def take_to.go source · line 152 · raw
@s:String -> @+stop:U32 -> @acc:String -> @hit:Bool -> Pair(String, String)
hit: the last char pushed onto acc was the stop char.
def take_to source · line 168 · raw
@s:String -> @stop:U32 -> Pair(String, String)
(text before the first stop char, text after it)
def pair source · line 171 · raw
@kv:String -> Pair(String, String)
def qput.decv source · line 174 · raw
@m:Map<&2, String> -> @key:String -> @v:Maybe<&2, String> -> Map<&2, String>
def qput.dec source · line 181 · raw
@m:Map<&2, String> -> @k:Maybe<&2, String> -> @v:Maybe<&2, String> -> Map<&2, String>
def qput.kv source · line 188 · raw
@m:Map<&2, String> -> @kv:Pair(String, String) -> Map<&2, String>
def qput source · line 192 · raw
@m:Map<&2, String> -> @kv:String -> Map<&2, String>
def qfold source · line 195 · raw
@xs:List<&2, String> -> @m:Map<&2, String> -> Map<&2, String>
def parse.q source · line 202 · raw
@path:String -> @rest:String -> @hasq:Bool -> Maybe<&2, Url>
def parse.path source · line 209 · raw
@path:Maybe<&2, String> -> @+rest:String -> Maybe<&2, Url>
def parse.split source · line 216 · raw
@pr:Pair(String, String) -> Maybe<&2, Url>
def parse.ok source · line 220 · raw
@+s:String -> @ok:Bool -> Maybe<&2, Url>
def parse source · line 227 · raw
@+s:String -> Maybe<&2, Url>
def enc.pairs.go source · line 230 · raw
@xs:List<&2, Sigma<&2, &2, String, _ => String>> -> @acc:String -> String
def enc.pairs source · line 237 · raw
@m:Map<&2, String> -> String
def encode.q source · line 240 · raw
@path:String -> @q:String -> @empty:Bool -> String
def encode.go source · line 247 · raw
@path:String -> @+q:String -> String
def encode source · line 250 · raw
@u:Url -> String
def form.drop source · line 254 · raw
@q:String -> @empty:Bool -> String
def form.go source · line 261 · raw
@+q:String -> String
def form source · line 265 · raw
@m:Map<&2, String> -> String
application/x-www-form-urlencoded. Space is %20.
def has source · line 275 · raw
@s:String -> @+c:U32 -> Bool
def auth_end source · line 282 · raw
@+c:U32 -> Bool
def take.back source · line 285 · raw
@acc:String -> @rest:String -> Pair(String, String)
def take_auth.go source · line 293 · raw
@s:String -> @acc:String -> @hit:Bool -> Pair(String, String)
§3.2: the authority runs to the first "/", "?" or "#".
def default_port source · line 308 · raw
@+scheme:String -> Maybe<&2, U32>
def abs.target source · line 311 · raw
@+pq:String -> String
def abs.fst source · line 314 · raw
@ab:Pair(String, String) -> String
def abs.build source · line 319 · raw
@scheme:String -> @host:String -> @port:Maybe<&2, U32> -> @rest:String -> Maybe<&2, Abs>
§3.5: the fragment is for the client; it never goes on the wire.
def abs.port.num source · line 326 · raw
@n:Maybe<&2, U32> -> Maybe<&2, U32>
def abs.port source · line 334 · raw
@+ps:String -> @dflt:Maybe<&2, U32> -> Maybe<&2, U32>
§3.2.3: an empty port means the scheme's default.
def abs.hostok source · line 337 · raw
@scheme:String -> @host:String -> @port:Maybe<&2, U32> -> @rest:String -> @ok:Bool -> Maybe<&2, Abs>
def abs.hostport source · line 345 · raw
@scheme:String -> @dflt:Maybe<&2, U32> -> @hp:Pair(String, String) -> @rest:String -> Maybe<&2, Abs>
§3.2.2: hosts are case-insensitive. IPv6 literals are refused (IPv4-only runtime).
def abs.auth.if source · line 350 · raw
@+scheme:String -> @auth:String -> @rest:String -> @creds:Bool -> Maybe<&2, Abs>
WHATWG fetch refuses URLs that carry credentials (user:pass@).
def abs.auth source · line 357 · raw
@scheme:String -> @ar:Pair(String, String) -> Maybe<&2, Abs>
def abs.slashes source · line 361 · raw
@scheme:String -> @+rest:String -> @ok:Bool -> Maybe<&2, Abs>
def abs.scheme source · line 368 · raw
@sr:Pair(String, String) -> Maybe<&2, Abs>
def absolute source · line 373 · raw
@s:String -> Maybe<&2, Abs>
scheme://host[:port][/path][?query][#fragment]
def abs.port.dflt source · line 376 · raw
@m:Maybe<&2, U32> -> U32
def host_field source · line 384 · raw
@a:Abs -> String
RFC 9110 §7.2: the Host field; the default port may be left out.
def dots.pop source · line 391 · raw
@stack:List<&2, String> -> List<&2, String>
def dots.push source · line 398 · raw
@seg:String -> @stack:List<&2, String> -> @dot:Bool -> @up:Bool -> List<&2, String>
def dots.join source · line 409 · raw
@xs:List<&2, String> -> @acc:String -> String
def dots.go source · line 417 · raw
@segs:List<&2, String> -> @stack:List<&2, String> -> @trail:Bool -> String
stack is reversed; trail: the last segment was "." or "..", so a "/" ends the path.
def dots.abs source · line 427 · raw
@xs:List<&2, String> -> String
def remove_dots source · line 435 · raw
@path:String -> String
§5.2.4 for an absolute path: "." and ".." segments go away.
def dir.go source · line 438 · raw
@s:String -> @+acc:String -> @last:String -> String
def dir source · line 447 · raw
@path:String -> String
§5.2.3: the base path up to and including its last "/".
def with_q source · line 450 · raw
@path:String -> @q:String -> @has_q:Bool -> String
def res.build source · line 457 · raw
@scheme:String -> @host:String -> @port:U32 -> @path:String -> @q:String -> @has_q:Bool -> Maybe<&2, Abs>
def res.pq source · line 464 · raw
@pq:Pair(String, String) -> @has_q:Bool -> PQ
def res.ref source · line 468 · raw
@+r:String -> PQ
def res.rel.go source · line 473 · raw
@+scheme:String -> @+host:String -> @+port:U32 -> @+bpath:String -> @+bq:String -> @+bhas:Bool -> @+rp:String -> @+q:String -> @+rhas:Bool -> Maybe<&2, Abs>
§5.2.2: an empty path keeps the base path (and its query unless one is given); "/..." replaces the path; anything else merges with the base directory.
def res.rel source · line 478 · raw
@scheme:String -> @host:String -> @port:U32 -> @bpath:String -> @bq:String -> @bhas:Bool -> @r:PQ -> Maybe<&2, Abs>
def res.base source · line 482 · raw
@+r:String -> @b:PQ -> @a:Abs -> Maybe<&2, Abs>
def res.local source · line 487 · raw
@+r:String -> @a:Abs -> Maybe<&2, Abs>
def abs.scheme_of source · line 491 · raw
@a:Abs -> String
def res.net source · line 495 · raw
@+r:String -> @a:Abs -> @net:Bool -> Maybe<&2, Abs>
def scheme.ok source · line 502 · raw
@s:String -> Bool
def abs.has_scheme source · line 510 · raw
@+pre:String -> @colon:Bool -> Bool
§3.1: a ":" before any "/", "?" or "#" with a valid scheme name before it.
def resolve source · line 514 · raw
@a:Abs -> @+ref:String -> Maybe<&2, Abs>
ref against base: absolute http(s) URLs as is, "//host...", "/path", "?q", or a relative path. Other schemes are None (fetch cannot follow them).