fix: Switch to stdlib Uri type
Should never have created separate Uri type
This commit is contained in:
		@@ -3,10 +3,9 @@ import gleam/int
 | 
			
		||||
import gleam/list
 | 
			
		||||
import gleam/option.{Some}
 | 
			
		||||
import gleam/string
 | 
			
		||||
import gleam/uri
 | 
			
		||||
import gleam/uri.{type Uri, Uri}
 | 
			
		||||
import gluri/internal/parser
 | 
			
		||||
import gluri/internal/utils
 | 
			
		||||
import gluri/types.{type Uri, Uri}
 | 
			
		||||
 | 
			
		||||
/// Parses a string to the RFC3986 standard.
 | 
			
		||||
/// `Error` is returned if it fails parsing.
 | 
			
		||||
@@ -151,32 +150,6 @@ pub fn are_equivalent(uri1: Uri, uri2: Uri) -> Bool {
 | 
			
		||||
  uri1 == uri2
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Converts a uri library Uri value to the Gleam stdlib Uri value
 | 
			
		||||
pub fn to_uri(uri: Uri) -> uri.Uri {
 | 
			
		||||
  uri.Uri(
 | 
			
		||||
    uri.scheme,
 | 
			
		||||
    uri.userinfo,
 | 
			
		||||
    uri.host,
 | 
			
		||||
    uri.port,
 | 
			
		||||
    uri.path,
 | 
			
		||||
    uri.query,
 | 
			
		||||
    uri.fragment,
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Converts a Gleam stdlib Uri value to a uri library Uri value
 | 
			
		||||
pub fn from_uri(uri: uri.Uri) -> Uri {
 | 
			
		||||
  Uri(
 | 
			
		||||
    uri.scheme,
 | 
			
		||||
    uri.userinfo,
 | 
			
		||||
    uri.host,
 | 
			
		||||
    uri.port,
 | 
			
		||||
    uri.path,
 | 
			
		||||
    uri.query,
 | 
			
		||||
    uri.fragment,
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Decodes a percent encoded string.
 | 
			
		||||
///
 | 
			
		||||
/// Will return an `Error` if the encoding is not valid
 | 
			
		||||
 
 | 
			
		||||
@@ -4,11 +4,10 @@ import gleam/list.{Continue, Stop}
 | 
			
		||||
import gleam/option.{None, Some}
 | 
			
		||||
import gleam/result
 | 
			
		||||
import gleam/string
 | 
			
		||||
import gleam/uri.{type Uri, Uri, empty}
 | 
			
		||||
import gluri/internal/utils
 | 
			
		||||
import splitter
 | 
			
		||||
 | 
			
		||||
import gluri/types.{type Uri, Uri, empty_uri}
 | 
			
		||||
 | 
			
		||||
pub fn parse(uri: String) -> Result(Uri, Nil) {
 | 
			
		||||
  case parse_scheme(uri) {
 | 
			
		||||
    Ok(#(scheme, rest)) -> {
 | 
			
		||||
@@ -42,9 +41,9 @@ fn parse_query(str: String) -> Result(#(Uri, String), Nil) {
 | 
			
		||||
  case str {
 | 
			
		||||
    "?" <> rest -> {
 | 
			
		||||
      let #(query, rest) = get_multiple_optional(parse_query_fragment, rest)
 | 
			
		||||
      Ok(#(Uri(..empty_uri, query: Some(query)), rest))
 | 
			
		||||
      Ok(#(Uri(..empty, query: Some(query)), rest))
 | 
			
		||||
    }
 | 
			
		||||
    _ -> Ok(#(empty_uri, str))
 | 
			
		||||
    _ -> Ok(#(empty, str))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -52,9 +51,9 @@ fn parse_fragment(str: String) -> Result(#(Uri, String), Nil) {
 | 
			
		||||
  case str {
 | 
			
		||||
    "#" <> rest -> {
 | 
			
		||||
      let #(fragment, rest) = get_multiple_optional(parse_query_fragment, rest)
 | 
			
		||||
      Ok(#(Uri(..empty_uri, fragment: Some(fragment)), rest))
 | 
			
		||||
      Ok(#(Uri(..empty, fragment: Some(fragment)), rest))
 | 
			
		||||
    }
 | 
			
		||||
    _ -> Ok(#(empty_uri, str))
 | 
			
		||||
    _ -> Ok(#(empty, str))
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ import gleam/list
 | 
			
		||||
import gleam/option.{type Option, None, Some}
 | 
			
		||||
import gleam/result
 | 
			
		||||
import gleam/string
 | 
			
		||||
import gluri/types.{type Uri, Uri}
 | 
			
		||||
import gleam/uri.{type Uri, Uri}
 | 
			
		||||
import splitter.{type Splitter}
 | 
			
		||||
 | 
			
		||||
pub const scheme_port = [
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +0,0 @@
 | 
			
		||||
import gleam/option.{type Option, None}
 | 
			
		||||
 | 
			
		||||
pub type Uri {
 | 
			
		||||
  Uri(
 | 
			
		||||
    scheme: Option(String),
 | 
			
		||||
    userinfo: Option(String),
 | 
			
		||||
    host: Option(String),
 | 
			
		||||
    port: Option(Int),
 | 
			
		||||
    path: String,
 | 
			
		||||
    query: Option(String),
 | 
			
		||||
    fragment: Option(String),
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Blank Uri value
 | 
			
		||||
pub const empty_uri = Uri(None, None, None, None, "", None, None)
 | 
			
		||||
		Reference in New Issue
	
	Block a user