apiaryio / gavel2html

Renders HTML diff from Gavel.js output
MIT License
0 stars 0 forks source link

Fixes dollar sign handling in a body #28

Closed artem-zakharchenko closed 3 years ago

artem-zakharchenko commented 3 years ago

If the expected/actual values contain a dollar sign $ it gets treated as a string replacement sequence when the diff is wrapped in a wrapWith template string:

https://github.com/apiaryio/gavel2html/blob/8788847be0ba2aed566a13563a91c1598ce30809/src/converter.coffee#L47-L48

This can be remediated in two steps:

  1. Escape the $ string character to prevent it from being treated as a string replace sequence.
  2. Provide a function to the @wrapWith.replace call, so it ignores string replace sequences.