Skip to content

Commit

Permalink
Merge pull request #76 from line-o/fix/find-redirects
Browse files Browse the repository at this point in the history
Fix find redirects
  • Loading branch information
joewiz authored Feb 21, 2022
2 parents 3deb386 + d2664cc commit b48648f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 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)
};
5 changes: 2 additions & 3 deletions modules/find.xq
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ xquery version "3.1";
: The info parameter can be used for troubleshooting
:)

import module namespace app="http://exist-db.org/xquery/app" at "app.xqm";
import module namespace config="http://exist-db.org/xquery/apps/config" at "config.xqm";
import module namespace versions="http://exist-db.org/apps/public-repo/versions" at "versions.xqm";

Expand Down Expand Up @@ -45,9 +44,9 @@ return
$newest-compatible-package/@path
}
else if ($zip) then
response:redirect-to(xs:anyURI($abs-public || $xar-filename || ".zip"))
app:redirect-to($abs-public || $xar-filename || ".zip")
else
response:redirect-to(xs:anyURI($abs-public || $xar-filename))
app:redirect-to($abs-public || $xar-filename)
else
(
response:set-status-code(404),
Expand Down

0 comments on commit b48648f

Please sign in to comment.