phetsims / tandem

Simulation-side code for PhET-iO
MIT License
0 stars 5 forks source link

Copy/paste duplication and inconsistency between all of the regexes for `isValidTandemName` #270

Closed samreid closed 1 year ago

samreid commented 2 years ago

More generally, there is copy/paste duplication and inconsistency between all of the regexes for isValidTandemName. Should we create our own data structure to make it possible to "tack on" more allowed characters for certain cases?

Also note: DynamicTandem doesn't allow commas. That is a problem too.

zepumph commented 1 year ago

Ok, trying to get a handle on this issue:

  1. There is duplicated regex chars/definitions in Tandem and DynamicTandem
  2. It isn't clear if DynamicTandem wants less chars supported (][,-) or if it is just out of sync
  3. It is kind hard to know how to factor this out. Something like const regexBaseCharsAllowed = 'A-z0-9. . . '; And then we use new RegExp() to fill it in, or add the _ in dynamic tandem.

Adding to the PhET-iO backlog over in https://github.com/phetsims/phet-io/issues/1914

samreid commented 1 year ago

Looking great, thanks! @zepumph also volunteered to put some RegExp constants nearby Tandem.BASE_TANDEM_TERM.

zepumph commented 1 year ago

Thanks for helping me get this. I like where we got it.