Permalink
Browse files

Add escapeText function.

We should/will probably remove the escapeString function then…
  • Loading branch information...
1 parent fd73bc8 commit 915de0123d0a291f3c182ce2e93e829e6fc19654 @adimit adimit committed Aug 26, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 Text/Search/Sphinx.hs
@@ -8,6 +8,7 @@
-- buildKeyWords, escapeString, status, open, close
module Text.Search.Sphinx
( escapeString
+ , escapeText
, query
, buildExcerpts
, runQueries
@@ -68,6 +69,11 @@ escapeString (x:xs) = if x `elem` escapedChars
then '\\':x:escapeString xs
else x:escapeString xs
+escapeText :: Text -> Text
+escapeText = X.concatMap (\x -> if x `elem` escapedChars
+ then X.pack $ '\\':[x]
+ else X.singleton x)
+
-- | The 'query' function runs a single query against the Sphinx daemon.
-- To pipeline multiple queries in a batch, use addQuery and runQueries
query :: Configuration -- ^ The configuration

0 comments on commit 915de01

Please sign in to comment.