We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

The Profane

Not only do we validate that Chirps are under 140 characters, but we also have a list of words that are not allowed.

Assignment

We need to update the /api/validate_chirp endpoint to replace all "profane" words with 4 asterisks: ****.

  • kerfuffle
  • sharbert
  • fornax

Be sure to match against uppercase versions of the words as well, but not punctuation. "Sharbert!" does not need to be replaced, we'll consider it a different word due to the exclamation point.

Example Input

{
  "body": "This is a kerfuffle opinion I need to share with the world"
}

Example Output

{
  "cleaned_body": "This is a **** opinion I need to share with the world"
}

Run and submit the CLI tests.

Tips

Use an HTTP client to test your POST requests.

I'd recommend breaking the bad word replacement into a separate function. You can even write some unit tests for it!

Here are some useful standard library functions: