Skip to content

Commit

Permalink
[fix] 302 redirects
Browse files Browse the repository at this point in the history
Add new function `app:redirect-to#1 to replace response:redirect-to#1 until
eXist-db/exist#4249 is fixed.
  • Loading branch information
line-o committed Feb 21, 2022
1 parent caeb5a5 commit d2664cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
11 changes: 10 additions & 1 deletion modules/app.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ declare function app:view-package($node as node(), $model as map(*), $mode as xs
()
)
return
response:redirect-to(xs:anyURI($info-url))
app:redirect-to($info-url)
(: view current package info :)
else
let $packages := $package-group//package
Expand Down Expand Up @@ -441,3 +441,12 @@ declare function app:requires-to-english($requires as element()) {
else
" version " || $config:default-exist-version
};

(:~
: helper function to work around a bug in response:redirect-to#1
: see https://github.com/eXist-db/exist/issues/4249
:)
declare function app:redirect-to ($location as xs:string) {
response:set-status-code(302),
response:set-header("Location", $location)
};
12 changes: 4 additions & 8 deletions modules/find.xq
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,10 @@ return
$newest-compatible-package/version ! attribute version {.},
$newest-compatible-package/@path
}
else if ($zip) then (
response:set-status-code(302),
response:set-header("Location", $abs-public || $xar-filename || ".zip")
)
else (
response:set-status-code(302),
response:set-header("Location", $abs-public || $xar-filename)
)
else if ($zip) then
app:redirect-to($abs-public || $xar-filename || ".zip")
else
app:redirect-to($abs-public || $xar-filename)
else
(
response:set-status-code(404),
Expand Down

0 comments on commit d2664cc

Please sign in to comment.