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

Incorrect 404 served for directories which have dots in the name #120

Open
pavelgrinchenko opened this issue Apr 10, 2020 · 1 comment
Open
Labels
bug Something isn't working

Comments

@pavelgrinchenko
Copy link

Hi! We have such directories names in our static website /public/doc/changelog/0.18
And when serve-handler handles requests we have 404 for such pages.
I found reason - there is false-positive extname checking here https://github.com/zeit/serve-handler/blob/master/src/index.js#L610
But I'm not sure how it should be resolved. Maybe this check can follow next one (where handles cleanUrl)

Our config if it's important

serveHandler(req, res, {
    public: 'public',
    cleanUrls: true,
    trailingSlash: false,
    directoryListing: false,
    headers: [
      {
        source: '**/*.@(jpg|jpeg|gif|png)',
        headers: [
          {
            key: 'Cache-Control',
            value: 'max-age=86400'
          }
        ]
      },
      {
        source: '!**/*.@(jpg|jpeg|gif|png)',
        headers: [
          {
            key: 'Cache-Control',
            value: 'max-age=0'
          }
        ]
      }
    ]
  })
@styfle styfle added the bug Something isn't working label Feb 1, 2021
@styfle styfle changed the title Incorrect behaviour for directories which have dots in the name Incorrect 404 served for directories which have dots in the name Feb 1, 2021
@warren-bank
Copy link

shameless self-promotion alert:
this feature is fixed in my @warren-bank/serve fork of serve

abubakriz added a commit to abubakriz/serve-handler that referenced this issue Jul 31, 2024
When a file url has certain symbols like number sign (#), it doesn't encode them, which makes the browser fail to navigate to the file, thinking it is a document section. This commit fixes that by encoding urls using the built-in encodeURIComponent function.

Fixes vercel#120, vercel#205, vercel/serve#726, and vercel/serve#774
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