performPatternMatch :: CharlotteResponse -> Text -> Int -> Text -> SearchPattern -> Maybe Match
performPatternMatch resp curPath depth ref pat = do
  let body = responseBody resp
      pat' = spPattern pat
      pat'' = encodeUtf8 pat' :: ByteString
      body' = toStrict body
      hasMatch = pat'' `isInfixOf` body'
      invertMatch = spInvertMatch pat
  if hasMatch && not invertMatch
      then Just $ Match curPath pat depth ref (mkMatchInfo pat'' body')
      else if invertMatch && not hasMatch then
          Just $ Match curPath pat depth ref []
          else Nothing
performPatternMatch :: CharlotteResponse -> Text -> Int -> Text -> SearchPattern -> Maybe Match
performPatternMatch resp curPath depth ref pat = do
  let body = responseBody resp
      pat' = spPattern pat
      pat'' = encodeUtf8 pat' :: ByteString
      body' = toStrict body
      hasMatch = pat'' `isInfixOf` body'
      invertMatch = spInvertMatch pat
  if hasMatch && not invertMatch
      then Just $ Match curPath pat depth ref (mkMatchInfo pat'' body')
      else if invertMatch && not hasMatch then
          Just $ Match curPath pat depth ref []
          else Nothing
performPatternMatch resp curPath depth ref pat = do
  let body = responseBody resp
      pat' = spPattern pat
      pat'' = encodeUtf8 pat' :: ByteString
      body' = toStrict body
      hasMatch = pat'' `isInfixOf` body'
      invertMatch = spInvertMatch pat
  if hasMatch && not invertMatch
      then Just $ Match curPath pat depth ref (mkMatchInfo pat'' body')
      else if invertMatch && not hasMatch then
          Just $ Match curPath pat depth ref []
          else Nothing