~/bend-docscommunity

LAWS.bend source

LAWS.bend on the hub · documented module

import Baseimport ./lib.bend as U# Construction and rendering.law make_show:  { U.Url.to_string(U.Url{ "http", "example.com", "/a", "x=1" })      == "http://example.com/a?x=1" : String }law build_alias:  { U.Url.build(U.Url{ "https", "example.com", "", "" })      == "https://example.com" : String }law show_alias:  { U.Url.show(U.Url{ "https", "example.com", "/", "q" })      == "https://example.com/?q" : String }# Accepted absolute forms.law parse_http:  { U.Url.parse("http://example.com")      == Some{U.Url{ "http", "example.com", "", "" }}      : Maybe<&2, U.Url> }law parse_https_path_query:  { U.Url.parse("https://example.com/a/b?x=1")      == Some{U.Url{ "https", "example.com", "/a/b", "x=1" }}      : Maybe<&2, U.Url> }law parse_empty_path_query:  { U.Url.parse("http://example.com?x")      == Some{U.Url{ "http", "example.com", "", "x" }}      : Maybe<&2, U.Url> }law parse_trailing_slash:  { U.Url.parse("http://example.com/")      == Some{U.Url{ "http", "example.com", "/", "" }}      : Maybe<&2, U.Url> }law parse_repeated_path_slash:  { U.Url.parse("http://example.com/a//b")      == Some{U.Url{ "http", "example.com", "/a//b", "" }}      : Maybe<&2, U.Url> }law parse_roundtrip:  { U.Url.parse(U.Url.to_string(U.Url{ "https", "host", "/p", "a=b" }))      == Some{U.Url{ "https", "host", "/p", "a=b" }}      : Maybe<&2, U.Url> }# Rejected forms outside the v1 grammar.law reject_relative:  { U.Url.parse("/relative/path") == None{} : Maybe<&2, U.Url> }law reject_wrong_scheme:  { U.Url.parse("ftp://example.com") == None{} : Maybe<&2, U.Url> }law reject_upper_scheme:  { U.Url.parse("HTTP://example.com") == None{} : Maybe<&2, U.Url> }law reject_empty_host:  { U.Url.parse("http:///path") == None{} : Maybe<&2, U.Url> }law reject_userinfo:  { U.Url.parse("http://user@example.com/") == None{} : Maybe<&2, U.Url> }law reject_fragment:  { U.Url.parse("http://example.com/p#part") == None{} : Maybe<&2, U.Url> }law reject_second_query:  { U.Url.parse("http://example.com/p?a?b") == None{} : Maybe<&2, U.Url> }# Relative path joining.law join_empty_path:  { U.Url.to_string(U.Url.join_path(      U.Url{ "https", "example.com", "", "" }, "api"))      == "https://example.com/api" : String }law join_nested_path:  { U.Url.to_string(U.Url.join_path(      U.Url{ "https", "example.com", "/api", "q" }, "v1"))      == "https://example.com/api/v1?q" : String }law join_trailing_slash:  { U.Url.to_string(U.Url.join_path(      U.Url{ "http", "example.com", "/api/", "" }, "v1"))      == "http://example.com/api/v1" : String }law join_empty_segment:  { U.Url.join_path(      U.Url{ "http", "example.com", "/api", "q" }, "")      == U.Url{ "http", "example.com", "/api", "q" } : U.Url }law join_preserves_query:  { U.Url.join_path(      U.Url{ "http", "example.com", "", "a=1" }, "next")      == U.Url{ "http", "example.com", "/next", "a=1" } : U.Url }