rust-lang / rust-lang/mdBook

Trailing "/" (slashes) at the end of URL brings out the error 404, not found page

Open
#2,432 1 comment 0 reactions 1 assignee View on GitHub

@riojosdev is already working on this.

Since Aug 26, 2024.

C-bug
Dominant language
Rust
Stars
22.2k
Forks
1.9k
PR merge metrics
PR metrics pending

Description

Problem

Trailing slashes "/" at the end of the URL, even if the file extension is an ".html" file, the renderer calls the 404 page. This might be done following the RFC 1738. Which represents with slashes at the end as a directory like "example.com/directory/" & without slashes representing a file like so "example.com/file.ext"

The following information was found regarding this:

https://developers.google.com/search/blog/2010/04/to-slash-or-not-to-slash

https://stackoverflow.com/questions/5948659/when-should-i-use-a-trailing-slash-in-my-url

https://datatracker.ietf.org/doc/rfc1738/

Steps
  1. Add a trailing single forward slash / at the end of url ending with .html
Possible Solution(s)

The renderer should check whether the not found error is caused by an "allowed character", here in this case is a forward slash /. And if yes, then recheck if file exists by removing the "allowed character".

Notes

Using a list of "allowed character" to bypass certain http status codes, is a debatable topic. Will this feature be misused? Certain special characters could cause a different functionality to be executed by the browsers.

Version
mdbook v0.4.40

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.