Skip to content

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

@jonrimmer

Description

@jonrimmer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions