Hello community,

here is the log from the commit of package ghc-wai-app-static for 
openSUSE:Factory checked in at 2016-08-26 23:17:16
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-wai-app-static (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-wai-app-static.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-wai-app-static"

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-wai-app-static/ghc-wai-app-static.changes    
2016-07-20 09:19:23.000000000 +0200
+++ 
/work/SRC/openSUSE:Factory/.ghc-wai-app-static.new/ghc-wai-app-static.changes   
    2016-08-26 23:17:17.000000000 +0200
@@ -1,0 +2,10 @@
+Sun Aug 21 17:30:16 UTC 2016 - [email protected]
+
+- Update to version 3.1.6.1 revision 0 with cabal2obs.
+
+-------------------------------------------------------------------
+Wed Aug 17 18:37:00 UTC 2016 - [email protected]
+
+- Update to version 3.1.6 revision 0 with cabal2obs.
+
+-------------------------------------------------------------------

Old:
----
  wai-app-static-3.1.5.tar.gz

New:
----
  wai-app-static-3.1.6.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-wai-app-static.spec ++++++
--- /var/tmp/diff_new_pack.Bzfo4J/_old  2016-08-26 23:17:19.000000000 +0200
+++ /var/tmp/diff_new_pack.Bzfo4J/_new  2016-08-26 23:17:19.000000000 +0200
@@ -19,14 +19,13 @@
 %global pkg_name wai-app-static
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        3.1.5
+Version:        3.1.6.1
 Release:        0
 Summary:        WAI application for static serving
 License:        MIT
-Group:          System/Libraries
+Group:          Development/Languages/Other
 Url:            https://hackage.haskell.org/package/%{pkg_name}
 Source0:        
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
-# Begin cabal-rpm deps:
 BuildRequires:  chrpath
 BuildRequires:  ghc-Cabal-devel
 BuildRequires:  ghc-blaze-builder-devel
@@ -58,10 +57,10 @@
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 %if %{with tests}
 BuildRequires:  ghc-hspec-devel
+BuildRequires:  ghc-mockery-devel
 BuildRequires:  ghc-network-devel
 BuildRequires:  ghc-temporary-devel
 %endif
-# End cabal-rpm deps
 
 %description
 API docs and the README are available at
@@ -81,22 +80,15 @@
 %prep
 %setup -q -n %{pkg_name}-%{version}
 
-
 %build
 %ghc_lib_build
 
-
 %install
 %ghc_lib_install
-
 %ghc_fix_dynamic_rpath warp
 
-
 %check
-%if %{with tests}
-%{cabal} test
-%endif
-
+%cabal_test
 
 %post devel
 %ghc_pkg_recache

++++++ wai-app-static-3.1.5.tar.gz -> wai-app-static-3.1.6.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-app-static-3.1.5/ChangeLog.md 
new/wai-app-static-3.1.6.1/ChangeLog.md
--- old/wai-app-static-3.1.5/ChangeLog.md       2016-03-29 08:32:12.000000000 
+0200
+++ new/wai-app-static-3.1.6.1/ChangeLog.md     2016-08-17 14:30:56.000000000 
+0200
@@ -1,3 +1,12 @@
+## 3.1.6.1
+
+* Add `<>` import
+
+## 3.1.6
+
+* Make ssAddTrailingSlash work in combination with ssIndices 
[#569](https://github.com/yesodweb/wai/pull/569)
+* Make ssIndices work with ssLookupFile and trailing slashes 
[#570](https://github.com/yesodweb/wai/pull/570)
+
 ## 3.1.5
 
 * Switch to cryponite
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/wai-app-static-3.1.5/Network/Wai/Application/Static.hs 
new/wai-app-static-3.1.6.1/Network/Wai/Application/Static.hs
--- old/wai-app-static-3.1.5/Network/Wai/Application/Static.hs  2016-03-29 
08:32:12.000000000 +0200
+++ new/wai-app-static-3.1.6.1/Network/Wai/Application/Static.hs        
2016-08-17 14:30:56.000000000 +0200
@@ -87,14 +87,14 @@
         Nothing -> return $ WaiResponse $ W.responseLBS H.status403
             [ ("Content-Type", "text/plain")
             ] "Directory listings disabled"
+
+addTrailingSlash :: W.Request -> Maybe ByteString
+addTrailingSlash req
+    | S8.null rp = Just "/"
+    | S8.last rp == '/' = Nothing
+    | otherwise = Just $ S8.snoc rp '/'
   where
-    addTrailingSlash :: W.Request -> Maybe ByteString
-    addTrailingSlash req
-        | S8.null rp = Just "/"
-        | S8.last rp == '/' = Nothing
-        | otherwise = Just $ S8.snoc rp '/'
-      where
-        rp = W.rawPathInfo req
+    rp = W.rawPathInfo req
 
 checkPieces :: StaticSettings
             -> Pieces                    -- ^ parsed request
@@ -108,45 +108,49 @@
 checkPieces ss@StaticSettings {..} pieces req = do
     res <- lookupResult
     case res of
-        Left location -> return $ RawRedirect $ TE.encodeUtf8 location
+        Left location -> return $ RawRedirect location
         Right LRNotFound -> return NotFound
         Right (LRFile file) -> serveFile ss req file
         Right (LRFolder folder) -> serveFolder ss pieces req folder
   where
-    lookupResult :: IO (Either Text LookupResult)
+    lookupResult :: IO (Either ByteString LookupResult)
     lookupResult = do
       nonIndexResult <- ssLookupFile pieces
       case nonIndexResult of
           LRFile{} -> return $ Right nonIndexResult
           _ -> do
-              indexResult <- lookupIndices (map (\ index -> pieces ++ [index]) 
ssIndices)
-              return $ case indexResult of
-                  LRNotFound -> Right nonIndexResult
-                  LRFile file | ssRedirectToIndex ->
-                      let relPath =
-                              case reverse pieces of
-                                  -- Served at root
-                                  [] -> fromPiece $ fileName file
-                                  lastSegment:_ ->
-                                      case fromPiece lastSegment of
-                                          -- Ends with a trailing slash
-                                          "" -> fromPiece $ fileName file
-                                          -- Lacks a trailing slash
-                                          lastSegment' -> T.concat
-                                              [ lastSegment'
-                                              , "/"
-                                              , fromPiece $ fileName file
-                                              ]
-                       in Left relPath
-                  _ -> Right indexResult
+              eIndexResult <- lookupIndices (map (\ index -> dropLastIfNull 
pieces ++ [index]) ssIndices)
+              return $ case eIndexResult of
+                  Left redirect -> Left redirect
+                  Right indexResult -> case indexResult of
+                      LRNotFound -> Right nonIndexResult
+                      LRFile file | ssRedirectToIndex ->
+                          let relPath =
+                                  case reverse pieces of
+                                      -- Served at root
+                                      [] -> fromPiece $ fileName file
+                                      lastSegment:_ ->
+                                          case fromPiece lastSegment of
+                                              -- Ends with a trailing slash
+                                              "" -> fromPiece $ fileName file
+                                              -- Lacks a trailing slash
+                                              lastSegment' -> T.concat
+                                                  [ lastSegment'
+                                                  , "/"
+                                                  , fromPiece $ fileName file
+                                                  ]
+                           in Left $ TE.encodeUtf8 relPath
+                      _ -> Right indexResult
 
-    lookupIndices :: [Pieces] -> IO LookupResult
+    lookupIndices :: [Pieces] -> IO (Either ByteString LookupResult)
     lookupIndices (x : xs) = do
         res <- ssLookupFile x
         case res of
             LRNotFound -> lookupIndices xs
-            _ -> return res
-    lookupIndices [] = return LRNotFound
+            _ -> return $ case (ssAddTrailingSlash, addTrailingSlash req) of
+                (True, Just redirect) -> Left redirect
+                _ -> Right res
+    lookupIndices [] = return $ Right LRNotFound
 
 serveFile :: StaticSettings -> W.Request -> File -> IO StaticResponse
 serveFile StaticSettings {..} req file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-app-static-3.1.5/Util.hs 
new/wai-app-static-3.1.6.1/Util.hs
--- old/wai-app-static-3.1.5/Util.hs    2016-03-29 08:32:12.000000000 +0200
+++ new/wai-app-static-3.1.6.1/Util.hs  2016-08-17 14:30:56.000000000 +0200
@@ -1,9 +1,10 @@
-{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE OverloadedStrings, ViewPatterns #-}
 module Util
     ( relativeDirFromPieces
     , defaultMkRedirect
     , replace
     , remove
+    , dropLastIfNull
     ) where
 
 import WaiAppStatic.Types
@@ -36,3 +37,9 @@
     | otherwise = relDir `S8.append` S8.tail newPath
   where
     relDir = TE.encodeUtf8 (relativeDirFromPieces pieces)
+
+dropLastIfNull :: [Piece] -> [Piece]
+dropLastIfNull pieces = case pieces of
+    [fromPiece -> ""] -> []
+    (a : r) -> a : dropLastIfNull r
+    [] -> []
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-app-static-3.1.5/WaiAppStatic/CmdLine.hs 
new/wai-app-static-3.1.6.1/WaiAppStatic/CmdLine.hs
--- old/wai-app-static-3.1.5/WaiAppStatic/CmdLine.hs    2016-03-29 
08:32:12.000000000 +0200
+++ new/wai-app-static-3.1.6.1/WaiAppStatic/CmdLine.hs  2016-08-17 
14:30:56.000000000 +0200
@@ -25,6 +25,7 @@
 import WaiAppStatic.Types (ssIndices, toPiece, ssGetMimeType, fileName, 
fromPiece)
 import Data.Maybe (mapMaybe)
 import Control.Arrow (second)
+import Data.Monoid ((<>))
 
 data Args = Args
     { docroot :: FilePath
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-app-static-3.1.5/test/EmbeddedTestEntries.hs 
new/wai-app-static-3.1.6.1/test/EmbeddedTestEntries.hs
--- old/wai-app-static-3.1.5/test/EmbeddedTestEntries.hs        2016-03-29 
08:32:12.000000000 +0200
+++ new/wai-app-static-3.1.6.1/test/EmbeddedTestEntries.hs      2016-08-17 
14:30:56.000000000 +0200
@@ -47,4 +47,9 @@
   , EmbeddableEntry "index.html"
                     "text/html"
                     (Right [| return ("" :: T.Text, "index file") |] )
+
+    -- An index file in a subdir
+  , EmbeddableEntry "foo/index.html"
+                    "text/html"
+                    (Right [| return ("" :: T.Text, "index file in subdir") |] 
)
   ]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-app-static-3.1.5/test/WaiAppEmbeddedTest.hs 
new/wai-app-static-3.1.6.1/test/WaiAppEmbeddedTest.hs
--- old/wai-app-static-3.1.5/test/WaiAppEmbeddedTest.hs 2016-03-29 
08:32:12.000000000 +0200
+++ new/wai-app-static-3.1.6.1/test/WaiAppEmbeddedTest.hs       2016-08-17 
14:30:56.000000000 +0200
@@ -41,6 +41,15 @@
               assertStatus 200 req
               assertBody "index file" req
 
+        it "ssIndices works with trailing slashes" $ do
+            let testSettings = $(mkSettings mkEntries){
+                    ssIndices = [unsafeToPiece "index.html"]
+                }
+            embedSettings testSettings $ do
+              req <- request (setRawPathInfo defRequest "/foo/")
+              assertStatus 200 req
+              assertBody "index file in subdir" req
+
     describe "embedded, uncompressed entry" $ do
         it "too short" $ embed $ do
             req <- request (setRawPathInfo defRequest "e2.txt")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-app-static-3.1.5/test/WaiAppStaticTest.hs 
new/wai-app-static-3.1.6.1/test/WaiAppStaticTest.hs
--- old/wai-app-static-3.1.5/test/WaiAppStaticTest.hs   2016-03-29 
08:32:12.000000000 +0200
+++ new/wai-app-static-3.1.6.1/test/WaiAppStaticTest.hs 2016-08-17 
14:30:56.000000000 +0200
@@ -5,6 +5,7 @@
 import WaiAppStatic.Types
 
 import Test.Hspec
+import Test.Mockery.Directory
 import qualified Data.ByteString.Char8 as S8
 -- import qualified Data.ByteString.Lazy.Char8 as L8
 import System.PosixCompat.Files (getFileStatus, modificationTime)
@@ -136,6 +137,16 @@
         assertStatus 301 req
         assertHeader "Location" "/a/" req
 
+      it "works when an index.html is delivered" $ do
+        let settings = (defaultFileServerSettings "."){
+              ssAddTrailingSlash = True
+            }
+        inTempDirectory $ fileServerAppWithSettings settings $ do
+          liftIO $ touch "foo/index.html"
+          req <- request (setRawPathInfo defRequest "/foo")
+          assertStatus 301 req
+          assertHeader "Location" "/foo/" req
+
       let urlMapApp = flip runSession $ \req send ->
             case pathInfo req of
                 "subPath":rest ->
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-app-static-3.1.5/wai-app-static.cabal 
new/wai-app-static-3.1.6.1/wai-app-static.cabal
--- old/wai-app-static-3.1.5/wai-app-static.cabal       2016-03-29 
08:32:12.000000000 +0200
+++ new/wai-app-static-3.1.6.1/wai-app-static.cabal     2016-08-17 
14:30:56.000000000 +0200
@@ -1,5 +1,5 @@
 name:            wai-app-static
-version:         3.1.5
+version:         3.1.6.1
 license:         MIT
 license-file:    LICENSE
 author:          Michael Snoyman <[email protected]>
@@ -101,6 +101,7 @@
                    , zlib
                    , filepath
                    , temporary
+                   , mockery
                    -- , containers
   ghc-options:   -Wall
 


Reply via email to