network-uri 2.6.0.3 → 2.6.1.0
raw patch · 3 files changed
+75/−4 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Network.URI: instance Constructor C1_0URI
- Network.URI: instance Data URI
- Network.URI: instance Data URIAuth
- Network.URI: instance Datatype D1URI
- Network.URI: instance Eq URI
- Network.URI: instance Eq URIAuth
- Network.URI: instance Generic URI
- Network.URI: instance NFData URI
- Network.URI: instance NFData URIAuth
- Network.URI: instance Ord URI
- Network.URI: instance Ord URIAuth
- Network.URI: instance Selector S1_0_0URI
- Network.URI: instance Selector S1_0_1URI
- Network.URI: instance Selector S1_0_2URI
- Network.URI: instance Selector S1_0_3URI
- Network.URI: instance Selector S1_0_4URI
- Network.URI: instance Show URI
- Network.URI: instance Show URIAuth
- Network.URI: instance Typeable URI
- Network.URI: instance Typeable URIAuth
- Network.URI: uriAuthority :: URI -> Maybe URIAuth
- Network.URI: uriFragment :: URI -> String
- Network.URI: uriPath :: URI -> String
- Network.URI: uriPort :: URIAuth -> String
- Network.URI: uriQuery :: URI -> String
- Network.URI: uriRegName :: URIAuth -> String
- Network.URI: uriScheme :: URI -> String
- Network.URI: uriUserInfo :: URIAuth -> String
+ Network.URI: [uriAuthority] :: URI -> Maybe URIAuth
+ Network.URI: [uriFragment] :: URI -> String
+ Network.URI: [uriPath] :: URI -> String
+ Network.URI: [uriPort] :: URIAuth -> String
+ Network.URI: [uriQuery] :: URI -> String
+ Network.URI: [uriRegName] :: URIAuth -> String
+ Network.URI: [uriScheme] :: URI -> String
+ Network.URI: [uriUserInfo] :: URIAuth -> String
+ Network.URI: instance Control.DeepSeq.NFData Network.URI.URI
+ Network.URI: instance Control.DeepSeq.NFData Network.URI.URIAuth
+ Network.URI: instance Data.Data.Data Network.URI.URI
+ Network.URI: instance Data.Data.Data Network.URI.URIAuth
+ Network.URI: instance GHC.Classes.Eq Network.URI.URI
+ Network.URI: instance GHC.Classes.Eq Network.URI.URIAuth
+ Network.URI: instance GHC.Classes.Ord Network.URI.URI
+ Network.URI: instance GHC.Classes.Ord Network.URI.URIAuth
+ Network.URI: instance GHC.Generics.Constructor Network.URI.C1_0URI
+ Network.URI: instance GHC.Generics.Datatype Network.URI.D1URI
+ Network.URI: instance GHC.Generics.Generic Network.URI.URI
+ Network.URI: instance GHC.Generics.Selector Network.URI.S1_0_0URI
+ Network.URI: instance GHC.Generics.Selector Network.URI.S1_0_1URI
+ Network.URI: instance GHC.Generics.Selector Network.URI.S1_0_2URI
+ Network.URI: instance GHC.Generics.Selector Network.URI.S1_0_3URI
+ Network.URI: instance GHC.Generics.Selector Network.URI.S1_0_4URI
+ Network.URI: instance GHC.Show.Show Network.URI.URI
+ Network.URI: instance GHC.Show.Show Network.URI.URIAuth
+ Network.URI: pathSegments :: URI -> [String]
Files
- Network/URI.hs +28/−2
- network-uri.cabal +2/−2
- tests/uri001.hs +45/−0
Network/URI.hs view
@@ -103,6 +103,7 @@ , escapeURIChar , escapeURIString , unEscapeString+ , pathSegments -- * URI Normalization functions , normalizeCase@@ -126,12 +127,16 @@ import Control.Applicative import Control.Monad (MonadPlus(..))-import Data.Traversable (sequenceA) import Control.DeepSeq (NFData(rnf), deepseq) import Data.Char (ord, chr, isHexDigit, toLower, toUpper, digitToInt) import Data.Bits ((.|.),(.&.),shiftL,shiftR)+import Data.List (unfoldr) import Numeric (showIntAtBase) +#if !MIN_VERSION_base(4,8,0)+import Data.Traversable (sequenceA)+#endif+ import Data.Typeable (Typeable) #if MIN_VERSION_base(4,0,0) import Data.Data (Data)@@ -871,11 +876,15 @@ -- | Returns 'True' if the character is allowed unescaped in a URI. --+-- >>> escapeURIString isUnescapedInURI "http://haskell.org:80?some_param=true&other_param=їґ"+-- "http://haskell.org:80?some_param=true&other_param=%D1%97%D2%91" isUnescapedInURI :: Char -> Bool isUnescapedInURI c = isReserved c || isUnreserved c -- | Returns 'True' if the character is allowed unescaped in a URI component. --+-- >>> escapeURIString isUnescapedInURIComponent "http://haskell.org:80?some_param=true&other_param=їґ"+-- "http%3A%2F%2Fhaskell.org%3A80%3Fsome_param%3Dtrue%26other_param%3D%D1%97%D2%91" isUnescapedInURIComponent :: Char -> Bool isUnescapedInURIComponent c = not (isReserved c || not (isUnescapedInURI c)) @@ -1080,7 +1089,24 @@ (r,'/':ps1) -> (r++"/",ps1) (r,_) -> (r,[]) --- Split last (name) segment from path, returning (path,name)+segments :: String -> [String]+segments str = dropLeadingEmpty $ unfoldr nextSegmentMaybe str+ where+ nextSegmentMaybe "" = Nothing+ nextSegmentMaybe ps =+ case break (=='/') ps of+ (seg, '/':ps1) -> Just (seg, ps1)+ (seg, _) -> Just (seg, "")+ dropLeadingEmpty ("":xs) = xs+ dropLeadingEmpty xs = xs++-- | Returns the segments of the path component. E.g.,+-- pathSegments <$> parseURI "http://example.org/foo/bar/baz"+-- == ["foo", "bar", "baz"]+pathSegments :: URI -> [String]+pathSegments = segments . uriPath++-- | Split last (name) segment from path, returning (path,name) splitLast :: String -> (String,String) splitLast p = (reverse revpath,reverse revname) where
network-uri.cabal view
@@ -1,8 +1,8 @@ name: network-uri-version: 2.6.0.3+version: 2.6.1.0 synopsis: URI manipulation description:- This package provides an URI manipulation inteface.+ This package provides an URI manipulation interface. . In network-2.6 the @Network.URI@ module was split off from the network package into this package. If you're using the @Network.URI@
tests/uri001.hs view
@@ -48,11 +48,13 @@ , isUnescapedInURIComponent , isUnescapedInURI, escapeURIString, unEscapeString , normalizeCase, normalizeEscape, normalizePathSegments+ , pathSegments ) import Test.HUnit import Data.Maybe (fromJust)+import Data.List (intercalate) import System.IO (openFile, IOMode(WriteMode), hClose) import qualified Test.Framework as TF import qualified Test.Framework.Providers.HUnit as TF@@ -1259,6 +1261,48 @@ , TF.testCase "testIsRelative04" $ testUriIsRelative "?what=that" ] +testPathSegmentsRoundTrip :: URI -> Assertion+testPathSegmentsRoundTrip u =+ let segs = pathSegments u++ dropSuffix _suf [] = []+ dropSuffix suf [x] | suf == x = []+ | otherwise = [x]+ dropSuffix suf (x:xs) = x : dropSuffix suf xs++ dropPrefix _pre [] = []+ dropPrefix pre (x:xs) | pre == x = xs+ | otherwise = (x:xs)+ strippedUriPath = dropSuffix '/' $ dropPrefix '/' $ uriPath u+ in+ (Data.List.intercalate "/" segs @?= strippedUriPath)++assertJust _f Nothing = assertFailure "URI failed to parse"+assertJust f (Just x) = f x++testPathSegments = TF.testGroup "testPathSegments"+ [ TF.testCase "testPathSegments03" $+ assertJust testPathSegmentsRoundTrip $ parseURIReference ""+ , TF.testCase "testPathSegments04" $+ assertJust testPathSegmentsRoundTrip $ parseURIReference "/"+ , TF.testCase "testPathSegments05" $+ assertJust testPathSegmentsRoundTrip $ parseURIReference "//"+ , TF.testCase "testPathSegments06" $+ assertJust testPathSegmentsRoundTrip $ parseURIReference "foo//bar/"+ , TF.testCase "testPathSegments07" $+ assertJust testPathSegmentsRoundTrip $ parseURIReference "/foo//bar/"+ , TF.testCase "testPathSegments03" $+ assertJust testPathSegmentsRoundTrip $ parseURI "http://example.org"+ , TF.testCase "testPathSegments04" $+ assertJust testPathSegmentsRoundTrip $ parseURI "http://example.org/"+ , TF.testCase "testPathSegments05" $+ assertJust testPathSegmentsRoundTrip $ parseURI "http://example.org//"+ , TF.testCase "testPathSegments06" $+ assertJust testPathSegmentsRoundTrip $ parseURI "http://ex.ca/foo//bar/"+ , TF.testCase "testPathSegments07" $+ assertJust testPathSegmentsRoundTrip $ parseURI "http://ex.ca/foo//bar/"+ ]+ -- Full test suite allTests = [ testURIRefSuite@@ -1274,6 +1318,7 @@ , testAltFn , testIsAbsolute , testIsRelative+ , testPathSegments ] main = TF.defaultMain allTests