Merge pull request #81 from begriffs/content-location
Fix Content-Location header when there are no params
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ app conn req respond =
|
|||||||
rawQueryString req
|
rawQueryString req
|
||||||
return $ addHeaders [
|
return $ addHeaders [
|
||||||
("Content-Location",
|
("Content-Location",
|
||||||
"/" <> cs table <> "?" <> cs canonical
|
"/" <> cs table <> if null canonical then "" else "?" <> cs canonical
|
||||||
)] r
|
)] r
|
||||||
|
|
||||||
([table], "POST") ->
|
([table], "POST") ->
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ spec = around appWithFixture $ do
|
|||||||
, matchHeaders = ["Content-Range" <:> "0-1/2"]
|
, matchHeaders = ["Content-Range" <:> "0-1/2"]
|
||||||
}
|
}
|
||||||
|
|
||||||
describe "Canonical location" $
|
describe "Canonical location" $ do
|
||||||
it "Sets Content-Location with alphabetized params" $
|
it "Sets Content-Location with alphabetized params" $
|
||||||
get "/no_pk?b=eq.1&a=eq.1"
|
get "/no_pk?b=eq.1&a=eq.1"
|
||||||
`shouldRespondWith` ResponseMatcher {
|
`shouldRespondWith` ResponseMatcher {
|
||||||
@@ -44,3 +44,11 @@ spec = around appWithFixture $ do
|
|||||||
, matchStatus = 200
|
, matchStatus = 200
|
||||||
, matchHeaders = ["Content-Location" <:> "/no_pk?a=eq.1&b=eq.1"]
|
, matchHeaders = ["Content-Location" <:> "/no_pk?a=eq.1&b=eq.1"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it "Omits question mark when there are no params" $
|
||||||
|
get "/no_pk"
|
||||||
|
`shouldRespondWith` ResponseMatcher {
|
||||||
|
matchBody = Just "[]"
|
||||||
|
, matchStatus = 200
|
||||||
|
, matchHeaders = ["Content-Location" <:> "/no_pk"]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user