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

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

Open
GreenImp opened this issue Mar 5, 2025 · 0 comments · May be fixed by #71
Open

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

GreenImp opened this issue Mar 5, 2025 · 0 comments · May be fixed by #71

Comments

@GreenImp
Copy link
Contributor

GreenImp commented Mar 5, 2025

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.

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

Successfully merging a pull request may close this issue.

1 participant