Skip to content

[Bug] Backing class JavaScript file not working if path contains underscore #70

@didoo

Description

@didoo

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 + 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

screenshot_1879

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

screenshot_1880

You can see that it works by the lack of`0` zero after the `Count` text and clicking the button triggers this error:

screenshot_1882

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

screenshot_1874

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

screenshot_1877

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

screenshot_1878

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

screenshot_1873

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions