Hello community, here is the log from the commit of package ghc-wai-extra for openSUSE:Factory checked in at 2016-01-21 23:43:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-wai-extra (Old) and /work/SRC/openSUSE:Factory/.ghc-wai-extra.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-wai-extra" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-wai-extra/ghc-wai-extra.changes 2016-01-07 00:25:08.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-wai-extra.new/ghc-wai-extra.changes 2016-01-22 01:08:20.000000000 +0100 @@ -1,0 +2,6 @@ +Fri Jan 15 10:21:47 UTC 2016 - mimi...@gmail.com + +- update to 3.0.14 +* Middleware to force domain names. + +------------------------------------------------------------------- Old: ---- wai-extra-3.0.13.1.tar.gz New: ---- wai-extra-3.0.14.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-wai-extra.spec ++++++ --- /var/tmp/diff_new_pack.o5Bz0e/_old 2016-01-22 01:08:22.000000000 +0100 +++ /var/tmp/diff_new_pack.o5Bz0e/_new 2016-01-22 01:08:22.000000000 +0100 @@ -21,7 +21,7 @@ %bcond_with tests Name: ghc-wai-extra -Version: 3.0.13.1 +Version: 3.0.14 Release: 0 Summary: Provides some basic WAI handlers and middleware License: MIT ++++++ wai-extra-3.0.13.1.tar.gz -> wai-extra-3.0.14.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wai-extra-3.0.13.1/ChangeLog.md new/wai-extra-3.0.14/ChangeLog.md --- old/wai-extra-3.0.13.1/ChangeLog.md 2015-12-30 07:49:09.000000000 +0100 +++ new/wai-extra-3.0.14/ChangeLog.md 2016-01-12 14:53:39.000000000 +0100 @@ -1,3 +1,7 @@ +## 3.0.14 + +* Middleware to force domain names. [#506](https://github.com/yesodweb/wai/issues/506) [#507](https://github.com/yesodweb/wai/pull/507) + ## 3.0.13.1 * Support wai 3.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wai-extra-3.0.13.1/Network/Wai/Middleware/ForceDomain.hs new/wai-extra-3.0.14/Network/Wai/Middleware/ForceDomain.hs --- old/wai-extra-3.0.13.1/Network/Wai/Middleware/ForceDomain.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/wai-extra-3.0.14/Network/Wai/Middleware/ForceDomain.hs 2016-01-12 14:53:39.000000000 +0100 @@ -0,0 +1,38 @@ +-- | +-- +-- @since 3.0.14 +module Network.Wai.Middleware.ForceDomain where + +import Data.ByteString (ByteString) +import Data.Monoid ((<>), mempty) +import Network.HTTP.Types (hLocation, methodGet, status301, status307) +import Prelude + +import Network.Wai +import Network.Wai.Request + +-- | Force a domain by redirecting. +-- The `checkDomain` function takes the current domain and checks whether it is correct. +-- It should return `Nothing` if the domain is correct, or `Just "domain.com"` if it is incorrect. +-- +-- @since 3.0.14 +forceDomain :: (ByteString -> Maybe ByteString) -> Middleware +forceDomain checkDomain app req sendResponse = + case requestHeaderHost req >>= checkDomain of + Nothing -> + app req sendResponse + Just domain -> + sendResponse $ redirectResponse domain + + where + -- From: Network.Wai.Middleware.ForceSSL + redirectResponse domain = + responseBuilder status [(hLocation, location domain)] mempty + + location h = + let p = if appearsSecure req then "https://" else "http://" in + p <> h <> rawPathInfo req <> rawQueryString req + + status + | requestMethod req == methodGet = status301 + | otherwise = status307 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wai-extra-3.0.13.1/Network/Wai/Middleware/Gzip.hs new/wai-extra-3.0.14/Network/Wai/Middleware/Gzip.hs --- old/wai-extra-3.0.13.1/Network/Wai/Middleware/Gzip.hs 2015-12-30 07:49:09.000000000 +0100 +++ new/wai-extra-3.0.14/Network/Wai/Middleware/Gzip.hs 2016-01-12 14:53:39.000000000 +0100 @@ -65,6 +65,7 @@ [ "application/json" , "application/javascript" , "application/ecmascript" + , "image/x-icon" ] -- | Use gzip to compress the body of the response. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wai-extra-3.0.13.1/wai-extra.cabal new/wai-extra-3.0.14/wai-extra.cabal --- old/wai-extra-3.0.13.1/wai-extra.cabal 2015-12-30 07:49:09.000000000 +0100 +++ new/wai-extra-3.0.14/wai-extra.cabal 2016-01-12 14:53:39.000000000 +0100 @@ -1,5 +1,5 @@ Name: wai-extra -Version: 3.0.13.1 +Version: 3.0.14 Synopsis: Provides some basic WAI handlers and middleware. description: Provides basic WAI handler and middleware functionality: @@ -141,6 +141,7 @@ Network.Wai.Middleware.Vhost Network.Wai.Middleware.HttpAuth Network.Wai.Middleware.StreamFile + Network.Wai.Middleware.ForceDomain Network.Wai.Middleware.ForceSSL Network.Wai.Middleware.Routed Network.Wai.Parse