Skip to content

Commit

Permalink
fix: tighten controller’s handling of API URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
joewiz committed Jul 16, 2024
1 parent 971ade5 commit e35ec1f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions controller.xql
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ else switch($path-parts[1])

(: handle requests for static resource: robots.txt :)
case "robots.txt"
case "opensearch.html"
case "opensearch.xml"
case "favicon.ico" return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<!-- TODO: add cache header! -->
Expand Down Expand Up @@ -664,7 +664,15 @@ else switch($path-parts[1])

(: handle OPDS API requests :)
case 'api' return
if ($path-parts[2] eq 'v1') then
if (
$path-parts[2] eq 'v1'
and
(
($path-parts[3] eq 'catalog' and empty($path-parts[4]))
or
($path-parts[3] eq 'catalog' and $path-parts[4] = ('all', 'recent', 'browse', 'search'))
)
) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/modules/opds-catalog.xql">
<add-parameter name="xql-application-url" value="{local:get-url()}"/>
Expand Down

0 comments on commit e35ec1f

Please sign in to comment.