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

Directory with 5.0 in path always serves 404 #139

Closed
JustinBeckwith opened this issue Jan 25, 2021 · 2 comments
Closed

Directory with 5.0 in path always serves 404 #139

JustinBeckwith opened this issue Jan 25, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@JustinBeckwith
Copy link

Lovely library - thank you for building it! I ran into a rather bizarre problem when trying to debug JustinBeckwith/linkinator#233. There is a route that looks like http://localhost:3000/docs/5.0/ which always returns a 404, even with an index.html in that local directory. I have a full simple reproduction here:
https://github.com/JustinBeckwith/serve-bug

The code is simple enough:

const http = require('http');
const serve = require('serve-handler');

http.createServer((req, res) => {
  return serve(req, res, {
    public: '.',
    directoryListing: false,
  });
})
.listen(3000);

With a directory structure like this:

/
  docs/
    normal/
      index.html
    6/
      index.html
    5.0/
      index.html

The routes that go to docs/normal and docs/6 work - only the 5.0 route causes a 404. Please do let me know if there's anything else I can do to help with a reproduction.

cc @XhmikosR

@XhmikosR
Copy link

XhmikosR commented Jan 25, 2021

@JustinBeckwith I had a quick look at this and it seems we need

  1. to set renderSingle: true
  2. and change the === 1 check to >= 1 here:
    const canRenderSingle = renderSingle && (files.length === 1);

Then linkinator is passing here:

> [email protected] docs-linkinator C:\Users\xmr\Desktop\bootstrap
> linkinator _gh_pages --recurse --silent --skip "^(?!http://localhost)"

🏊‍♂️ crawling _gh_pages
renderSingle: true
canRenderSingle: true
files.length: 15
🤖 Successfully scanned 700 links in 2.942 seconds.

docs/5.0/ contents:

 Directory of C:\Users\xmr\Desktop\bootstrap\_gh_pages\docs\5.0

25/01/2021  14:58    <DIR>          .
25/01/2021  14:58    <DIR>          ..
25/01/2021  14:58    <DIR>          about
25/01/2021  14:58    <DIR>          assets
25/01/2021  14:58    <DIR>          components
25/01/2021  14:58    <DIR>          content
25/01/2021  14:58    <DIR>          customize
31/08/1754  00:43    <DIR>          dist
25/01/2021  14:58    <DIR>          examples
25/01/2021  14:58    <DIR>          extend
25/01/2021  14:58    <DIR>          forms
25/01/2021  14:58    <DIR>          getting-started
25/01/2021  14:58    <DIR>          helpers
25/01/2021  14:58               498 index.html
25/01/2021  14:58    <DIR>          layout
25/01/2021  14:58    <DIR>          migration
25/01/2021  14:58    <DIR>          utilities

I haven't tested it with unit tests since I'm having trouble setting up the repo on vanilla Windows 10.

@styfle friendly CC in case you can help us here :)

EDIT: Alternatively, maybe the check should look for other sibling folders too or something?
EDIT2: BTW this might be a duplicate of #120?

@styfle styfle added the bug Something isn't working label Feb 1, 2021
@styfle
Copy link
Member

styfle commented Feb 1, 2021

Thanks for the repro steps!

Indeed, this does look like a duplicate of #120 so I'll close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants