Skip to content

Fix Incorrect suffix check #378

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix Incorrect suffix check #378

wants to merge 1 commit into from

Conversation

ptrgits
Copy link

@ptrgits ptrgits commented Aug 7, 2025

The best way to fix this problem is to use String.prototype.endsWith if available, as it directly checks for a suffix. If you want to support older environments, you can fall back to a manual check that compares the substring at the end of the string to the desired suffix. In this case, since the code is using ES6 imports and other modern features, it is safe to use endsWith. The fix should be applied to the isJS function in resources/watch.js, replacing the current indexOf check with filepath.endsWith('.js'). No additional imports or definitions are needed.

References

String.prototype.endsWith
String.prototype.indexOf

Copy link

linux-foundation-easycla bot commented Aug 7, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

@saihaj saihaj requested review from Copilot and ardatan August 8, 2025 04:08
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an incorrect suffix check in the isJS function by replacing a manual indexOf check with the more appropriate endsWith method. The change improves code clarity and correctness for determining if a file path has a .js extension.

  • Replaces manual suffix checking logic with String.prototype.endsWith
  • Improves readability and maintainability of the file extension check

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 this pull request may close these issues.

1 participant