[Bug] Backing class JavaScript file not working if path contains underscore
- Dominant language
- JavaScript
- Stars
- 19
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
Probably a bug. Did some experiments to understand why in some cases the backing class JavaScript file associated with a Markdown file was not picked up, and I've found a strange behaviour. If the path of the file (be it a parent folder, or the file itself) contains an underscore (`_`) then the JS file is ignored.
To test this I have forked this repo, and simply added a bunch of test files (direct copies of the [`custom-button.js`](https://github.com/empress/field-guide/blob/master/docs/components/custom-button.js) + [`custom-button.md`](https://github.com/empress/field-guide/blob/master/docs/components/custom-button.md) demo files) and checked what happened in different cases.
You can test yourself using this branch in my fork: https://github.com/didoo/field-guide-testing/tree/backing-class-path-underscore-bug/docs
Here's what I've found:
### With a simple file name and a parent folder that doesn't contain an underscore - It works ✅
- markdown file: `test-file.md`
- javascript file: `test-file.js`
- parent folder: `01-testing-normal-folder`
You can see that it works by the `0` zero visible after the `Count` text (and clicking the button increases the value).
### Same file but with an underscore in the name - It doesn't work ❌
- markdown file: `test-file_with_underscore.md`
- javascript file: `test-file_with_underscore.js`
- parent folder: `01-testing-normal-folder`
You can see that it works by the lack of`0` zero after the `Count` text and clicking the button triggers this error:

### Same file with a `0x--` prefix - It works ✅
- markdown file: `01--test-file-with-number-prefix.md`
- javascript file: `01--test-file-with-number-prefix.js`
- parent folder: `01-testing-normal-folder`

### Same file with a `0x_` prefix in both the Markdown and the JS files - It doesn't work ❌
- markdown file: `02_test-file-with-number-prefix-and-underscore.md`
- javascript file: `02_test-file-with-number-prefix-and-underscore.js`
- parent folder: `01-testing-normal-folder`

### Same file with a `0x_` prefix in the Markdown, but a normal dash in the JS file - Strangely, it works 🤔
- markdown file: `03_test-file-with-number-prefix-and-mixed.md`
- javascript file: `03-test-file-with-number-prefix-and-mixed.js`
- parent folder: `01-testing-normal-folder`

### Same file with a parent folder that contains an underscore - It doesn't work ❌
- markdown file: `test-file.md`
- javascript file: `test-file.js`
- parent folder: `02_testing-folder_with_underscore`

Contributor guide
Assessment
This issue has not been assessed yet.