Skip to content

Commit 1bbf4c6

Browse files
diemogebhardtlpil
authored andcommitted
Add Uri.empty constant representing an empty URI, equivalent to ""
1 parent 9548d28 commit 1bbf4c6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/gleam/uri.gleam

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,33 @@ pub type Uri {
2828
)
2929
}
3030

31+
/// Constant representing an empty URI, equivalent to "".
32+
///
33+
/// ## Examples
34+
///
35+
/// ```gleam
36+
/// let uri = Uri(..Uri.empty, scheme: Some("https"), host: Some("example.com"))
37+
/// // -> Uri(
38+
/// // scheme: Some("https"),
39+
/// // userinfo: None,
40+
/// // host: Some("example.com"),
41+
/// // port: None,
42+
/// // path: "",
43+
/// // query: None,
44+
/// // fragment: None,
45+
/// // )
46+
/// ```
47+
///
48+
pub const empty = Uri(
49+
scheme: None,
50+
userinfo: None,
51+
host: None,
52+
port: None,
53+
path: "",
54+
query: None,
55+
fragment: None,
56+
)
57+
3158
/// Parses a compliant URI string into the `Uri` Type.
3259
/// If the string is not a valid URI string then an error is returned.
3360
///

0 commit comments

Comments
 (0)