summaryrefslogtreecommitdiff
path: root/Main.hs
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2019-02-03 23:50:16 +0300
committerdefanor <defanor@uberspace.net>2019-02-03 23:50:16 +0300
commit7c376f213869209876e339fb66304c49f82aa363 (patch)
tree5646964a0f125c18acd2b4de2a9671a7e4a2b382 /Main.hs
parentd10783ddb88a6958009b377f07c3d0dde0087836 (diff)
Ignore duplicate parameters in XSLT
Maybe query parameters should instead be passed to XSLTs as a part of the document to process, but perhaps better to ignore duplicate ones for now.
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/Main.hs b/Main.hs
index bfee6f3..49408ee 100644
--- a/Main.hs
+++ b/Main.hs
@@ -55,6 +55,7 @@ import Control.Arrow ((***))
import Control.Exception (bracket, finally, catches, Handler(..))
import System.FilePath (replaceExtension, takeFileName, (</>))
import System.Envy (decodeEnv, FromEnv(..), envMaybe, (.!=))
+import Data.List (nubBy)
import Foreign
import Foreign.C
@@ -101,7 +102,8 @@ transform docBS baseStr pathStr stringParams =
alloca $ \lenPtr ->
bracket (notNull $ xmlReadMemory docCStr (fromIntegral docCStrLen) baseCStr nullPtr 0)
xmlFreeDoc $ \doc ->
- bracket (mapM newCString (concatMap (\(x, y) -> [x, y]) stringParams))
+ bracket (mapM newCString (concatMap (\(x, y) -> [x, y]) $
+ nubBy (\x y -> fst x == fst y) stringParams))
(mapM free) $ \params ->
withArray0 nullPtr params $ \paramsArr ->
withArray0 nullPtr [] $ \emptyArr ->