dart-lang/dartdoc

The generated library URLs need an ending slash

isoos opened this issue · 3 comments

isoos commented

The documentation URLs for libraries generated by 8.3.0 are missing an ending slash. When hosted, this breaks the sidebar and all relative links, as the base-uri reference is one directory up.

To fix that, the hosting needs to redirect from /library-x to /library-x/, and that is one extra request (extra latency) that could have been spared with the ending slash.

Related note: The change of the library URLs (#3895) is breaking pub.dev in multiple ways. We should explore how we could define a somewhat future-proof way to prevent or mitigate such disruptions. (We should also prevent situations where we need the beta SDK to analyze or generate sources for packages requiring the same beta SDK, but that's another discussion.)

I tested the new URLs only with serving the HTML files on disk via the dhttpd package, which I think behaves like vanilla Apache, and loads /index.html if it is available. But I guess this is not universal behavior. We can instead link to library-x/.

Thanks for the report, @isoos

isoos commented

Thanks for looking into it!

Btw. python -m http.server does the extra redirect:

127.0.0.1 - - [03/Dec/2024 09:16:47] "GET /analyzer/6.11.0/dart_ast_ast HTTP/1.1" 301 -
127.0.0.1 - - [03/Dec/2024 09:16:47] "GET /analyzer/6.11.0/dart_ast_ast/ HTTP/1.1" 200 -

And if the browser requested the URL without the ending slash and the webserver served the index.html without redirecting, it breaks the relative links and the sidebar loading, as they are one-level off (verified while adopting this to pub-dev).