refactor: Rewrote bool.guard to standard pattern match
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import gleam/bool
|
|
||||||
import gleam/int
|
import gleam/int
|
||||||
import gleam/list
|
import gleam/list
|
||||||
import gleam/option.{type Option, None, Some}
|
import gleam/option.{type Option, None, Some}
|
||||||
@@ -181,8 +180,10 @@ fn parse_authority_part(str: String) -> Result(#(Uri, String), Nil) {
|
|||||||
|
|
||||||
// userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
|
// userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
|
||||||
fn parse_userinfo(str: String) -> #(Option(String), String) {
|
fn parse_userinfo(str: String) -> #(Option(String), String) {
|
||||||
use <- bool.guard(when: !string.contains(str, "@"), return: #(None, str))
|
case string.contains(str, "@") {
|
||||||
do_parse_userinfo(str, "")
|
True -> do_parse_userinfo(str, "")
|
||||||
|
False -> #(None, str)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_parse_userinfo(str: String, userinfo: String) -> #(Option(String), String) {
|
fn do_parse_userinfo(str: String, userinfo: String) -> #(Option(String), String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user