From 428bd53002d26bf2e7509693c00129d319abb911 Mon Sep 17 00:00:00 2001 From: Gareth Pendleton Date: Sun, 14 Sep 2025 11:42:23 +0100 Subject: [PATCH] refactor: Changed tuple to type for clarity --- src/gluri/internal/utils.gleam | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gluri/internal/utils.gleam b/src/gluri/internal/utils.gleam index ac4bd13..369f393 100644 --- a/src/gluri/internal/utils.gleam +++ b/src/gluri/internal/utils.gleam @@ -7,17 +7,21 @@ import gleam/string import gleam/uri.{type Uri, Uri} import splitter.{type Splitter} -pub const scheme_port = [ - #("http", 80), - #("https", 443), - #("ftp", 21), - #("ws", 80), - #("wss", 443), +type Scheme { + Scheme(name: String, port: Int) +} + +const scheme_port = [ + 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) { - list.find(scheme_port, fn(sp) { sp.0 == scheme }) - |> result.map(fn(sp) { sp.1 }) + list.find(scheme_port, fn(sp) { sp.name == scheme }) + |> result.map(fn(sp) { sp.port }) |> option.from_result }