Docsify: URLs 404 when given a trailing slash /

Created on 11 Feb 2020  ·  13Comments  ·  Source: docsifyjs/docsify

Bug Report

Steps to reproduce

Go to any page path and add a trailing slash / to the end
Example: /#/hello/

What is current behaviour

The page apth /#/hello/ will 404

What is the expected behaviour

That the page requested is shown and works the same as /#/hello

Other relevant information


No

  • [x] Bug does still occur when all/other plugins are disabled?
  • Your OS: Windows 10
  • Node.js version: 8.11.3
  • npm/yarn version: 5.6.0
  • Browser version: Chrome Version 79.0.3945.130
  • Docsify version: latest unpkg (4.10.2)
  • Docsify plugins: search
PR Welcome bug help wanted

All 13 comments

Well,

/#/hello/ should not behave like /#/hello

Because, /#/hello means rendering /hello.md file.
according to your proposal, rendering /#/hello/ -> /hello.md will break the working of rendering the content of dir rendering.

/#/hello/ mean hello is a directory and docsify will look for homepage in it which is README.md by default.
changing the behavior of docsify to support /#/hello/ -> /hello.md will never able to render directory content.

if you have any other proposal to change the behavior, please comment. !!

cc @docsifyjs/core @trusktr @jthegedus Any proposal you guys want to give !!!

I think most websites on the internet with modern history routing render /hello/ and /hello as the same thing. This can cause Docsify sites to perform differently to what is expected by the average user.

I am not very familiar with routing modes and their differences, but maybe this is expected behaviour for hash mode routing in that you must be explicit with your trailing slash?

I will think on a proposal for a day.

In my opinion, I agree with @anikethsaha . this is the URI and URL issue.
Normally, when u visit the /hello/ means u wanna visit the /hello/index.html or /hello/default.html.
so, as for docsify, when you visit #/hello/ means u wanna visit #/hello/idk.md instead of the hello.md.

this is the URI and URL issue.
Normally, when u visit the /hello/ means u wanna visit the /hello/index.html or /hello/default.html.
so, as for docsify, when you visit #/hello/ means u wanna visit #/hello/idk.md instead of the hello.md.

Yeahh

I will think on a proposal for a day.

yea sure..

My initial comment was more questioning the difference between hash and history and if this was the cause.

Given 3 files:

  • hello.md
  • hello/homepage.md
  • hello/something.md

I agree that

/hello             -> /hello.md
/hello/            -> /hello/homepage.md
/hello/something   -> /hello/something.md

Where we can improve is what we do when there is no homepage.md in a path. Surely there's a better practice then just providing a 404 for this case?

Given 2 files:

  • hello.md
  • hello/something.md

The 404 seems wrong.

/hello             -> /hello.md
/hello/            -> 404
/hello/something   -> /hello/something.md

If we know there is not a homepage.md file/route, surely we can be more forgiving and redirect the user back to /hello.md, becoming:

/hello             -> /hello.md
/hello/            -> /hello.md (no homepage.md found so redirected to next pattern match of URL) 
/hello/something   -> /hello/something.md

I am not too fussed on the outcome here, though reading this issue reminded me of my first time using Docsify where I wished I didn't need to create intermediary index pages for all my routes. I just wanted to redirect back to another page of my liking that I knew existed, or the next match in the URL pattern.

@jthegedus I am +1 for the proposal you mentioned.

can you submit a PR with that. I am planning to do a release by this month. so It will be great if we ship this fix with it

@jthegedus your solution would make things behave more as expected, so looking forward to that :)

Agree with @jthegedus proposal, except to make it index.md instead of homepage.md

cc @jthegedus any update on this ?

I have not started work on this. Will give it a crack over the weekend. Help is welcome should anyone else find they have the time.

In GitHub Pages, isn't README.md is the index.html or default.html behavior? I mean it would make more sense to have a README.md as a convention.

I think we can default to README.md by matter of the existing
conventions, and we can also fall back to index.md if README.md is not
found. Thoughts?
#!/JoePea

On Mon, Jun 8, 2020 at 11:42 AM Kosala Nuwan Perera <
[email protected]> wrote:

In GitHub Pages, isn't README.md is the index.html or default.html
behavior? I mean it would make more sense to have a README.md as a
convention.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/docsifyjs/docsify/issues/1018#issuecomment-640803482,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AACIVTW5D6WZPWFIKE3S7ADRVUWIXANCNFSM4KTDGRKQ
.

@trusktr Of course index.md would do. But, I would expect the sub-folders must be treated similarly to the root. I think it should behave the same way how Docsify currently treating the docs/ root, i.e. a mixture of README.md and _coverpage.md. I believe these are the defaults of Docsify. Unless otherwise, the sub-folder itself is another Docsify-enabled site on its own.

Was this page helpful?
0 / 5 - 0 ratings