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

Serve file with default ext is same name dir cannot be shown #239

Open
jonrimmer opened this issue Mar 25, 2019 · 2 comments
Open

Serve file with default ext is same name dir cannot be shown #239

jonrimmer opened this issue Mar 25, 2019 · 2 comments

Comments

@jonrimmer
Copy link

I was trying to use Ecstatic (via http-server) to serve Angular's ES2015 modules. This means serving with .js default extension. I had problems because they have some files named e.g. metadata.js that also have a corresponding directory with the same name. Attempting to import ./metadata resolves to the directory, but since there is no index.js inside it, and showDir is false, this results in a 404. In this case, I think Ecstatic should fall back to serving the document with the default extension, if one exists.

I.e the proposed logic would be this:

  • If a file with the exact path exists: Serve it.
  • Else if a directory with the exact path exists:
    • If the directory has an index document: Serve it.
    • Else if the showDir: true: Show file list.
  • Else if a file with default extension exists: Serve it.
  • Else if 404.html exists: Serve it.
  • Else serve 404.
@jfhbrook
Copy link
Owner

jfhbrook commented Apr 5, 2019

This sounds like good stuff - I believe https://github.com/jfhbrook/node-ecstatic/blob/master/lib/ecstatic.js#L352-L371 is the code that would need to be refactored. A number of new tests would need to be written as well.

If someone wants to tackle this I would definitely take this!

@jfhbrook
Copy link
Owner

jfhbrook commented Apr 5, 2019

This issue is also likely relevant - in a similar location in the code and probably worth wrapping into the same PR: #88

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

No branches or pull requests

2 participants