Merge pull request #143 from txkaduo/master

Fix wildcards
This commit is contained in:
Christopher Reichert 2016-05-24 08:35:33 -05:00
commit 9ec0f5caf1
2 changed files with 12 additions and 1 deletions

View File

@ -240,7 +240,7 @@ lookupTree [] _ = Nothing
lookupTree _ EmptyLabelMap = Nothing
lookupTree [l] (Static t) = Map.lookup (CI.mk l) t >>= getPortEntry
--lookupTree (_:_) (Wildcard w) = getPortEntry $ w
lookupTree [_] (Wildcard w) = getPortEntry $ w
lookupTree [l] (WildcardExcept w t) =
case Map.lookup (CI.mk l) t >>= getPortEntry of
Just e -> Just e

View File

@ -8,12 +8,14 @@ import Test.Hspec
import Test.HUnit
import qualified Keter.LabelMap as LM
import Data.Maybe
spec :: Spec
spec = do
describe "LabelMap" $ do
it "modified subdmonains" caseSubdomainIntegrity
it "assert wildcards" caseWildcards
{-
@ -57,3 +59,12 @@ caseSubdomainIntegrity = do
print test3b
assertBool msg $ test3a == test3b
caseWildcards :: Assertion
caseWildcards = do
let test0 = LM.empty
test1 = LM.insert "*.someapp.com" () test0
test2 = LM.lookup "a.someapp.com" test1
msg = "Wildcards domains"
assertBool msg $ isJust test2