readthedocs / sphinx-notfound-page

Create a custom 404 page with absolute URLs hardcoded
https://sphinx-notfound-page.readthedocs.io/
MIT License
48 stars 32 forks source link

Read the Docs one `/_/` special URLs #214

Open humitos opened 1 year ago

humitos commented 1 year ago

If you go to https://docs.readthedocs.io/en/stable/notfound and open the Javascript console you will see that the file https://docs.readthedocs.io/en/stable/_/static/javascript/readthedocs-doc-embed.js returned 404. For some reason, this URL is being changed when it should not.

The valid URL for this case is https://docs.readthedocs.io/_/static/javascript/readthedocs-doc-embed.js. Note that it does not include /en/stable/

Related to #200 Related to #206

humitos commented 1 year ago

The valid URL for this case is https://docs.readthedocs.io/_/static/javascript/readthedocs-doc-embed.js. Note that it does not include /en/stable/

I suppose the URL injected by Read the Docs may be relative and that's why it's not working...

I checked for this in the source code and I found the following:

  1. https://github.com/rtfd/readthedocs-sphinx-ext/blob/673fbb09a5d268e73bf79da4cee3a193eab115a0/readthedocs_ext/readthedocs.py#L82
  2. https://github.com/readthedocs/readthedocs.org/blob/3b487c9877f91e2e67eb9854729608233959d29d/readthedocs/doc_builder/backends/sphinx.py#L186
  3. https://github.com/readthedocs/readthedocs.org/blob/3b487c9877f91e2e67eb9854729608233959d29d/readthedocs/projects/models.py#L633-L636

Executing that on docs project:

In [2]: p = Project.objects.get(slug='docs')

In [4]: p.proxied_static_path
Out[4]: '/_/static/'

So, the final URL would be /_/static/javascript/readthedocs-doc-embed.js. That URL should be skipped by the extension, in theory, due to this code we added before: https://github.com/rtfd/sphinx-notfound-page/blob/6f01c89834f21643836ce40cbcb4e017152dd757/notfound/extension.py#L100-L102