network-protocol-xmpp 0.3.2.5 → 0.3.3
raw patch · 2 files changed
+28/−27 lines, 2 filesdep ~gnuidnPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: gnuidn
API changes (from Hackage documentation)
Files
- Network/Protocol/XMPP/JID.hs +24/−23
- network-protocol-xmpp.cabal +4/−4
Network/Protocol/XMPP/JID.hs view
@@ -25,13 +25,14 @@ , parseJID_ , formatJID ) where-import qualified Data.Text.Lazy as T+import qualified Data.Text.Lazy as TL+import Data.Text.Lazy (Text) import qualified Data.Text.IDN.StringPrep as SP import Data.String (IsString, fromString) -newtype Node = Node { strNode :: T.Text }-newtype Domain = Domain { strDomain :: T.Text }-newtype Resource = Resource { strResource :: T.Text }+newtype Node = Node { strNode :: Text }+newtype Domain = Domain { strDomain :: Text }+newtype Resource = Resource { strResource :: Text } instance Show Node where showsPrec d (Node x) = showParen (d > 10) $@@ -68,48 +69,48 @@ instance IsString JID where fromString = parseJID_ . fromString -parseJID :: T.Text -> Maybe JID+parseJID :: Text -> Maybe JID parseJID str = maybeJID where (node, postNode) = case textSpanBy (/= '@') str of- (x, y) -> if T.null y+ (x, y) -> if TL.null y then ("", x)- else (x, T.drop 1 y)+ else (x, TL.drop 1 y) (domain, resource) = case textSpanBy (/= '/') postNode of- (x, y) -> if T.null y+ (x, y) -> if TL.null y then (x, "")- else (x, T.drop 1 y)- nullable x f = if T.null x then Just Nothing else fmap Just $ f x+ else (x, TL.drop 1 y)+ nullable x f = if TL.null x then Just Nothing else fmap Just $ f x maybeJID = do- preppedNode <- nullable node $ stringprepM SP.profileNodeprep- preppedDomain <- stringprepM SP.profileNameprep domain- preppedResource <- nullable resource $ stringprepM SP.profileResourceprep+ preppedNode <- nullable node $ stringprepM SP.xmppNode+ preppedDomain <- stringprepM SP.nameprep domain+ preppedResource <- nullable resource $ stringprepM SP.xmppResource return $ JID (fmap Node preppedNode) (Domain preppedDomain) (fmap Resource preppedResource)- stringprepM p x = case SP.stringprep p SP.defaultFlags x of+ stringprepM p x = case SP.stringprep p SP.defaultFlags (TL.toStrict x) of Left _ -> Nothing- Right y -> Just y+ Right y -> Just (TL.fromStrict y) -parseJID_ :: T.Text -> JID+parseJID_ :: Text -> JID parseJID_ text = case parseJID text of Just jid -> jid Nothing -> error "Malformed JID" -formatJID :: JID -> T.Text+formatJID :: JID -> Text formatJID (JID node (Domain domain) resource) = formatted where- formatted = T.concat [node', domain, resource']- node' = maybe "" (\(Node x) -> T.append x "@") node- resource' = maybe "" (\(Resource x) -> T.append "/" x) resource+ formatted = TL.concat [node', domain, resource']+ node' = maybe "" (\(Node x) -> TL.append x "@") node+ resource' = maybe "" (\(Resource x) -> TL.append "/" x) resource -- Similar to 'comparing' equaling :: Eq a => (b -> a) -> b -> b -> Bool equaling f x y = f x == f y -- multi-version 'text' compatibility-textSpanBy :: (Char -> Bool) -> T.Text -> (T.Text, T.Text)+textSpanBy :: (Char -> Bool) -> Text -> (Text, Text) #if MIN_VERSION_text(0,11,0)-textSpanBy = T.span+textSpanBy = TL.span #else-textSpanBy = T.spanBy+textSpanBy = TL.spanBy #endif
network-protocol-xmpp.cabal view
@@ -1,5 +1,5 @@ name: network-protocol-xmpp-version: 0.3.2.5+version: 0.3.3 synopsis: Client->Server XMPP license: GPL-3 license-file: License.txt@@ -11,12 +11,12 @@ category: Network stability: experimental bug-reports: mailto:jmillikin@gmail.com-homepage: http://john-millikin.com/software/network-protocol-xmpp/+homepage: https://john-millikin.com/software/hs-xmpp/ tested-with: GHC==6.12.1 source-repository head type: bazaar- location: http://john-millikin.com/software/network-protocol-xmpp/+ location: https://john-millikin.com/software/hs-xmpp/ library ghc-options: -Wall@@ -24,7 +24,7 @@ build-depends: base >= 3 && < 5 , text >= 0.10 && < 0.12- , gnuidn >= 0.1 && < 0.2+ , gnuidn >= 0.2 && < 0.3 , gnutls >= 0.1 && < 0.3 , bytestring >= 0.9 && < 0.10 , gsasl >= 0.3 && < 0.4