dns-patterns 0.1.2 → 0.1.3
raw patch · 4 files changed
+16/−7 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- dns-patterns.cabal +1/−1
- lib/Network/DNS/Pattern.hs +8/−3
- test/Spec.hs +3/−3
CHANGELOG.md view
@@ -11,3 +11,7 @@ ## 0.1.2 -- 2022-08-18 * Add 'foldCase' and 'foldCaseLabel'++## 0.1.3 -- 2022-08-19++* Fix incorrect Ord instance for 'Domain' and 'DomainLabel'
dns-patterns.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: dns-patterns-version: 0.1.2+version: 0.1.3 author: Victor Nawothnig maintainer: Victor Nawothnig (dminuoso@icloud.com) copyright: (c) 2022 Wobcom GmbH
lib/Network/DNS/Pattern.hs view
@@ -38,6 +38,7 @@ import Data.Char (isAscii, ord) import Data.Coerce (coerce) import Data.Foldable (asum, foldl')+import Data.Function (on) import Data.Word (Word8) import Text.Printf (printf) @@ -96,7 +97,6 @@ -- foo.bar.*. -- @ - type Parser = A.Parser -- | A domain pattern.@@ -112,19 +112,24 @@ -- | Newtype warpper for 'BS.ByteString' that implements case-insensitive 'Eq' and 'Ord' as per [RFC4343](https://datatracker.ietf.org/doc/html/rfc4343#section-3). newtype DomainLabel = DomainLabel { getDomainLabel :: BS.ByteString }- deriving (Ord) +instance Ord DomainLabel where+ compare = compare `on` (BS.map foldCase_ . getDomainLabel)+ instance Eq DomainLabel where DomainLabel l == DomainLabel r = BS.map foldCase_ l == BS.map foldCase_ r ++-- | Case-folding of a domain according to [RFC4343](https://datatracker.ietf.org/doc/html/rfc4343#section-3). foldCase :: Domain -> Domain foldCase (Domain ls) = Domain (foldCaseLabel <$> ls) --- | Case-folding according to [RFC4343](https://datatracker.ietf.org/doc/html/rfc4343#section-3).+-- | Case-folding of a domain label according to [RFC4343](https://datatracker.ietf.org/doc/html/rfc4343#section-3). foldCaseLabel :: DomainLabel -> DomainLabel foldCaseLabel (DomainLabel l) = DomainLabel (BS.map foldCase_ l) +{-# INLINE foldCase_ #-} foldCase_ :: Word8 -> Word8 foldCase_ x = case x of 0x41 -> c2w 'a'
test/Spec.hs view
@@ -29,13 +29,13 @@ Left err -> error ("Domain: no parse, " <> err) instance Show Domain where- showsPrec _ d = mappend (T.unpack (pprDomain d))+ show = T.unpack . pprDomain instance Show DomainPattern where- showsPrec _ d = mappend (T.unpack (pprPattern d))+ show = T.unpack . pprPattern instance Show DomainLabel where- showsPrec _ d = mappend (T.unpack (pprDomainLabel d))+ show = T.unpack . pprDomainLabel main :: IO () main = do