Skip to content

Folders are not redirected if missing a slash at the end #130

Open
@Maia-Everett

Description

@Maia-Everett

Expected behavior

If the requested URL points to a folder with an index.html file and it is missing a slash at the end, the server should respond with a redirect with a slash added at the end.

Actual behavior

If the requested URL points to a folder with an index.html file and it is missing a slash at the end, the server does not redirect with the slash added, making the browser think that the folder name is a file name, which in turn makes relative URLs work differently depending on whether or not the slash is present.

How to reproduce

  • Download and unpack this tiny project: koa-static-folder-bug.zip
  • npm install and npm start
  • Open http://localhost:3000/folder. Observe that no redirect took place. The image of a black square is displayed, even though image.png is in the parent directory of folder/index.html.
  • Open http://localhost:3000/folder/. Observe that the image is (correctly) not displayed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions