@@ -281,8 +281,12 @@ captureAllServer = handleLegs :<|> return
281
281
2 -> return tweety
282
282
_ -> throwError err404
283
283
284
+ type RootedCaptureAllApi = CaptureAll " xs" String :> Get '[JSON ] [String ]
285
+
284
286
captureAllSpec :: Spec
285
287
captureAllSpec = do
288
+ let getStringList = decode' @ [String ] . simpleBody
289
+
286
290
describe " Servant.API.CaptureAll" $ do
287
291
with (return (serve captureAllApi captureAllServer)) $ do
288
292
@@ -311,8 +315,6 @@ captureAllSpec = do
311
315
it " returns 400 if the decoding fails, even when it's multiple elements" $ do
312
316
get " /legs/1/0/0/notAnInt/3/orange/" `shouldRespondWith` 400
313
317
314
- let getStringList = decode' @ [String ] . simpleBody
315
-
316
318
it " can capture single String" $ do
317
319
response <- get " /arms/jerry"
318
320
liftIO $ getStringList response `shouldBe` Just [" jerry" ]
@@ -321,6 +323,19 @@ captureAllSpec = do
321
323
response <- get " /arms/"
322
324
liftIO $ getStringList response `shouldBe` Just []
323
325
326
+ it " can capture empty string from captureall" $ do
327
+ response <- get " /arms//"
328
+ liftIO $ getStringList response `shouldBe` Just [" " ]
329
+
330
+ with (return (serve (Proxy :: Proxy RootedCaptureAllApi ) return )) $ do
331
+ it " can capture empty rooted capture all" $ do
332
+ response <- get " /"
333
+ liftIO $ getStringList response `shouldBe` Just []
334
+
335
+ it " can capture empty string from rooted capture all" $ do
336
+ response <- get " //"
337
+ liftIO $ getStringList response `shouldBe` Just [" " ]
338
+
324
339
with (return (serve
325
340
(Proxy :: Proxy (CaptureAll " segments" String :> Raw ))
326
341
(\ _captured -> Tagged $ \ request_ sendResponse ->
0 commit comments