refactor: Changed tuple to type for clarity
This commit is contained in:
@@ -7,17 +7,21 @@ import gleam/string
|
|||||||
import gleam/uri.{type Uri, Uri}
|
import gleam/uri.{type Uri, Uri}
|
||||||
import splitter.{type Splitter}
|
import splitter.{type Splitter}
|
||||||
|
|
||||||
pub const scheme_port = [
|
type Scheme {
|
||||||
#("http", 80),
|
Scheme(name: String, port: Int)
|
||||||
#("https", 443),
|
}
|
||||||
#("ftp", 21),
|
|
||||||
#("ws", 80),
|
const scheme_port = [
|
||||||
#("wss", 443),
|
Scheme("http", 80),
|
||||||
|
Scheme("https", 443),
|
||||||
|
Scheme("ftp", 21),
|
||||||
|
Scheme("ws", 80),
|
||||||
|
Scheme("wss", 443),
|
||||||
]
|
]
|
||||||
|
|
||||||
pub fn get_port_for_scheme(scheme: String) -> Option(Int) {
|
pub fn get_port_for_scheme(scheme: String) -> Option(Int) {
|
||||||
list.find(scheme_port, fn(sp) { sp.0 == scheme })
|
list.find(scheme_port, fn(sp) { sp.name == scheme })
|
||||||
|> result.map(fn(sp) { sp.1 })
|
|> result.map(fn(sp) { sp.port })
|
||||||
|> option.from_result
|
|> option.from_result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user