Interface change for consistency: rewriteURL is idempotent on addresses with no matching rules.
parent
663f9b61dc
commit
6d12745fc9
|
@ -11,7 +11,7 @@ used secure HTTP connections when possible."
|
|||
λ: :m + Data.HTTPSEverywhere.Rules Network.URI
|
||||
λ: let Just eff = parseURI "http://www.eff.org/document/eff-and-aclu-amicus-brief-klayman"
|
||||
λ: rewriteURL eff
|
||||
Just https://www.eff.org/document/eff-and-aclu-amicus-brief-klayman
|
||||
https://www.eff.org/document/eff-and-aclu-amicus-brief-klayman
|
||||
λ: :m + Web.Cookie Network.HTTP.Client Data.Time.Clock Control.Applicative
|
||||
λ: :set -XOverloadedStrings
|
||||
λ: (now, req) <- (,) <$> getCurrentTime <*> parseUrl "https://github.com"
|
||||
|
|
|
@ -6,6 +6,7 @@ module Data.HTTPSEverywhere.Rules (
|
|||
import Prelude hiding (null, head)
|
||||
import Control.Lens ((<&>),(&))
|
||||
import Data.Bool (bool)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Network.HTTP.Client (Cookie)
|
||||
import Network.URI (URI)
|
||||
import Pipes ((>->))
|
||||
|
@ -13,8 +14,8 @@ import Pipes.Prelude (head, null)
|
|||
import Control.Monad (join)
|
||||
import Data.HTTPSEverywhere.Rules.Internal (getRulesetsMatching, havingRulesThatTrigger, havingCookieRulesThatTrigger, setSecureFlag)
|
||||
|
||||
rewriteURL :: URI -> IO (Maybe URI)
|
||||
rewriteURL url = getRulesetsMatching url >-> havingRulesThatTrigger url & head <&> join
|
||||
rewriteURL :: URI -> IO URI
|
||||
rewriteURL url = getRulesetsMatching url >-> havingRulesThatTrigger url & head <&> fromMaybe url . join
|
||||
|
||||
rewriteCookie :: URI -> Cookie -> IO Cookie
|
||||
rewriteCookie url cookie = null producer <&> setSecureFlag cookie `bool` cookie
|
||||
|
|
Loading…
Reference in New Issue