BUGFIX: Fix array of strings parsing for coding contracts #937
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a contract expects an array of strings, and the user manually submits it, parsing fails for arrays with spaces after the commas
e.g:
This is problematic because the examples for the coding contract show the strings formatted in this way:
Most common scripting languages will also by default format arrays in this way, so this error will happen to anyone directly pasting from them
The issue is that
removeQuotesFromString
will only remove quotes if they are either the first or last char in the string, so if there is whitespace at the start of the string before a quote, it will not remove it.bitburner-src/src/data/codingcontracttypes.ts
Lines 40 to 50 in ae8f26f
The current flow for answer validation is:
split on ','
->remove quote at start and/or end
->remove whitespace
This PR swaps the order to:
split on ','
->remove whitespace
->remove quote at start and/or end
This fixes the array spacing issue without any major refactor to
removeQuotesFromString
Video of built app running with the fixed validation:
testContract.mp4
closes #616
npm run format
npm run lint