1- import Http.Data.Uri .Authority
2- import Http.Data.Uri .Scheme
3- import Http.Data.Uri .Query
1+ import Http.Data.URI .Authority
2+ import Http.Data.URI .Scheme
3+ import Http.Data.URI .Query
44import Http.Util.Format
55import Http.Util
66import Http.Classes
@@ -14,22 +14,22 @@ open Lean
1414
1515* Reference: https://www.rfc-editor.org/rfc/rfc3986.html#section-3.2.2
1616 -/
17- structure Uri where
18- authority : Uri .Authority := {}
17+ structure URI where
18+ authority : URI .Authority := {}
1919 path : Option String := none
2020 query : Option String := none
2121 fragment : Option String := none
2222 deriving BEq, Repr, Inhabited
2323
24- def Uri .encode (input: String) : String :=
24+ def URI .encode (input: String) : String :=
2525 input.toUTF8.foldl (λs c => s ++ encodeChar c) ""
2626 where
2727 encodeChar char :=
2828 if (char ≥ 97 ∧ char ≤ 122 ) ∨ (char ≥ 65 ∧ char ≤ 90 ) ∨ (char ≥ 48 ∧ char ≤ 57 )
2929 then (Char.ofNat (UInt8.toNat char)).toString
3030 else s! "%{ (toHex char.toNat).toUpper} "
3131
32- def Uri .componentDecode (input: String) : Option String := Id.run do
32+ def URI .componentDecode (input: String) : Option String := Id.run do
3333 let mut result := ByteArray.empty
3434 let mut acc := 0
3535 let mut start := none
@@ -65,7 +65,7 @@ def Uri.componentDecode (input: String) : Option String := Id.run do
6565
6666 return String.fromAscii result
6767
68- instance : Canonical .text Uri where
68+ instance : Canonical .text URI where
6969 repr u :=
7070 let authority := Canonical.text u.authority
7171 let path := Option.getD u.path ""
@@ -74,6 +74,6 @@ instance : Canonical .text Uri where
7474 let notEncoded := String.join [authority, path, query, fragment]
7575 notEncoded
7676
77- namespace Uri
77+ namespace URI
7878
79- def empty : Uri := Uri .mk Inhabited.default none none none
79+ def empty : URI := URI .mk Inhabited.default none none none
0 commit comments