๐Ÿ€ ATproto library for gleam
atproto library gleam
34

Configure Feed

Select the types of activity you want to include in your feed.

possum/at_uri: pattern match on string before parsing

kacaii.dev (Jul 11, 2026, 11:22 AM -0300) 71f9b194 806d12b0

+15 -9
+15 -9
src/possum/at_uri.gleam
··· 12 12 pub type ParseError { 13 13 /// Only "at://" is supported 14 14 InvalidScheme(value: String) 15 - /// Authority is neither a valid DID or Handle 16 - InvalidAuthority(value: String) 15 + /// Authority not a valid Handle 16 + InvalidHandleAuthority(reason: handle.ParseError) 17 + /// Authority not a valid DID 18 + InvalidDidAuthority(reason: did.ParseError) 17 19 } 18 20 19 21 pub type Authority { ··· 109 111 } 110 112 111 113 fn parse_authority(string: String) -> Result(Authority, ParseError) { 112 - use _ <- result.try_recover(case did.parse(string) { 113 - Ok(value) -> Ok(Did(value)) 114 - Error(_) -> Error(InvalidAuthority(string)) 115 - }) 114 + case string { 115 + "did:" <> _rest -> 116 + case did.parse(string) { 117 + Ok(value) -> Ok(Did(value)) 118 + Error(reason) -> Error(InvalidDidAuthority(reason:)) 119 + } 116 120 117 - case handle.parse(string) { 118 - Ok(value) -> Ok(Handle(value)) 119 - Error(_) -> Error(InvalidAuthority(string)) 121 + _handle -> 122 + case handle.parse(string) { 123 + Ok(value) -> Ok(Handle(value)) 124 + Error(reason) -> Error(InvalidHandleAuthority(reason:)) 125 + } 120 126 } 121 127 } 122 128