More robust handling of endpoint URLs

The next goal is to redirect old-style /book/path/to/entry URLs to
/content/book/path/to/entry, which seemed pretty trivial.

However, given the current handling of some endpoint URLs, more work was
required to ensure that invalid endpoint URLs (e.g.  "/random/number" or
"/suggest/fr") are not interpreted as content URLs. Previously, that was
not a user-observable issue, since the result would be an immediate 404
error (except in certain edge cases, like handling the request for
"/random/number" when there is a book with name "random" containing an
article at path "/number"). With redirection of URLs that were assumed
to refer to content a 404 error would be issued for the
transformed URL ("/content/random/number") which may be confusing.

Therefore this change is to ensure the correct routing of endpoint URL
handling.
This commit is contained in:
Veloman Yunkan
2022-08-05 16:30:28 +04:00
parent fd36d11ccf
commit 3b98987cb3
3 changed files with 70 additions and 20 deletions

View File

@ -271,6 +271,7 @@ const char* urls404[] = {
"/ROOT/non-existent-item",
"/ROOT/skin/non-existent-skin-resource",
"/ROOT/catalog",
"/ROOT/catalog/",
"/ROOT/catalog/non-existent-item",
"/ROOT/catalogBLABLABLA/root.xml",
"/ROOT/catalog/v2/illustration/zimfile?size=48",
@ -281,9 +282,18 @@ const char* urls404[] = {
"/ROOT/meta?content=non-existent-book&name=title",
"/ROOT/random",
"/ROOT/random?content=non-existent-book",
"/ROOT/random/",
"/ROOT/random/number",
"/ROOT/suggest",
"/ROOT/suggest?content=non-existent-book&term=abcd",
"/ROOT/catch/external",
"/ROOT/suggest/",
"/ROOT/suggest/fr",
"/ROOT/search/",
"/ROOT/search/anythingotherthansearchdescription.xml",
"/ROOT/catch/",
"/ROOT/catch/external", // missing ?source=URL
"/ROOT/catch/external?source=",
"/ROOT/catch/anythingotherthanexternal",
"/ROOT/zimfile/A/non-existent-article",
"/ROOT/content/zimfile/A/non-existent-article",