Remove double underscores / hyphens from generated ids #316
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.
What does this change?
Titles may contain non-alpha-numeric characters however, the ids what we derive from these may not. When hyphens, colons etc are used in a title, the auto-generated ids fail validation, and it is not possible to launch the newsletter.
This PR updates the
deriveNewsletterFieldsFromName
function to strip out non-alpha-numeric characters and also, removes double underscores or hyphens (which also break validation rules for identifiers)The result is that the title is not constrained by the id validation rules.
How to test
On main, try creating a newsletter with a title containing non-numeric characters. EG:
foo ::: bar ------ Baz
The Stakes - US Election Edition
The above will fail at the point you attempt to launch. Now try again on this branch
How can we measure success?
The newsletter can be launched
Have we considered potential risks?
Up will now, it was only possible to use a-Z, 0-9 in titles - this enables use to use anything else. That anything else will be returned from the API. The API response is used in:
Is this OK?