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

Add safety for reserved words in buildNet #1063

Merged
merged 2 commits into from
Nov 21, 2023

Conversation

VitaliyR
Copy link
Contributor

Hi!

I was playing around with my pet project - and suddenly added word constructor as matcher for buildNet:

const matches = [
  { match: 'constructor' }
]
const net = nlp.buildNet(matches)

And when tried to run the code - it crashed because it tries to call push method on object.constructor which is a function.

I've fixed it via explicitly checking for types. What do you think?

P.S. Also not sure if thats the best place for test - feel free to point me into right direction. Thanks!

@spencermountain
Copy link
Owner

This is beautiful Vitalii!
thank you!

@spencermountain spencermountain changed the base branch from master to dev November 21, 2023 18:45
@spencermountain spencermountain merged commit 7d2c330 into spencermountain:dev Nov 21, 2023
@VitaliyR VitaliyR deleted the fix-build-net-props branch November 21, 2023 20:38
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.

2 participants