Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing slash breaks routing in docs website #445

Closed
mtanco opened this issue Dec 23, 2020 · 3 comments
Closed

Trailing slash breaks routing in docs website #445

mtanco opened this issue Dec 23, 2020 · 3 comments
Assignees
Labels
bug Bug in code docs Documentation

Comments

@mtanco
Copy link
Contributor

mtanco commented Dec 23, 2020

Actual behavior

When a URL has a trailing slash, any internal links that are not explicit to the file fail.

Expected behavior

Page to render instead of 404

Steps To Reproduce

Click on Gallery in the second to last section of the below page

Works

https://h2oai.github.io/wave/docs/tutorial-monitor goes to https://h2oai.github.io/wave/docs/examples

Doesn't Work

https://h2oai.github.io/wave/docs/tutorial-monitor/ goes to https://h2oai.github.io/wave/docs/tutorial-monitor/examples

Proposed Solution (needs testing)

This seems to be a docusaurus problem and they suggest, for now, using .md extensions and relative paths.
We'll need to do a bulk-replace of all our local links [Gallery](examples) to use extensions and relative paths

@mtanco mtanco added docs Documentation bug Bug in code labels Dec 23, 2020
@dulajra
Copy link
Contributor

dulajra commented Dec 24, 2020

@mtanco Even though we use the .md extension in URL if the user lands with a trailing / (i.e. examples/index.md/ ) then still the issue remains.

Here also using useBaseUrl function instead of markdown hyperlink will fix the problem.

<a href={useBaseUrl('docs/examples')}>Gallery</a>

@lo5 WDYT?

@lo5
Copy link
Member

lo5 commented Feb 17, 2021

@dulajra It would be good to figure out a way to fix this using plain markdown, without useBaseUrl everywhere. This is a problem with docusaurus: facebook/docusaurus#3372

@lo5 lo5 changed the title Trailing slash breaks internal routing Trailing slash breaks routing in docs website Mar 25, 2021
@MarkFarmiloe
Copy link

MarkFarmiloe commented Apr 10, 2021

In docusaurus/packages/docusaurus/src/client/normalizeLocation.ts
any trailing /index.html is knocked off the path.
If you knock off any trailing / as well with
pathname = pathname.replace(/\/$/, '');
on line 23, this seems to fix this bug.

But I don't know whether this would break anything else.
But it does seem to me that if you want to normalize, then allowing both /foo/bar/ and /foo/bar doesn't seem to be a very good job of normalizing to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in code docs Documentation
Projects
None yet
Development

No branches or pull requests

5 participants