Skip to content

File with name that exists in directory is parsed incorrectly #70

Open
@GreenImp

Description

@GreenImp

Describe the bug
If you have a file inside a directory, where the name of the file exists in the directory, then the list-folder functionality incorrectly removes the part of the directory name which matches the file name.

To Reproduce
Steps to reproduce the behavior:

  1. Create a file directory ./src/aNamedDirectory/
  2. In the directory, create a file called Named.js
  3. Build the docs
  4. See that the file is "Excluded"

This is because it is removing the Named part of the directory, so the file path is incorrect:

./src/aDirectory/Named.js

I think this is just supposed to be removing the filename and extension from the end of the string.

Expected behavior
It shouldn't remove parts of the directory name.

Node (please complete the following information):

  • Node-Version: 23.7.0

Additional context
This issue is caused by this line doing an indiscriminate replace:

const folder = filePath.replace(name, '').replace(ext, '');

I think it can be fixed by using path.parse as mentioned here: https://stackoverflow.com/a/31615711

I've managed to get it working locally, so I'll raise a PR to fix it.

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