summaryrefslogtreecommitdiffhomepage
path: root/scripts/utils/host
diff options
context:
space:
mode:
authorTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-10-23 16:53:42 +0200
committerTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-10-27 15:36:50 +0100
commit36b5ee4fd20bf882c214baa839dfef43515a875b (patch)
treefe584f393de29481b85bc9fc0d4177d1a89d727d /scripts/utils/host
parentb8ff10c6506fa2944220f32e83155e29b23b96e7 (diff)
downloadmullvadvpn-36b5ee4fd20bf882c214baa839dfef43515a875b.tar.xz
mullvadvpn-36b5ee4fd20bf882c214baa839dfef43515a875b.zip
Rewrite formatHtml to fix bugs in previous implementation
When the functionality to format `em` tags was added a buggy behavior was introduced. This buggy behavior stems from the logic to match the input string against the tags we want to format, namely <b> and <em>. We mistakenly operate against the original string at all times when we match each tag, which means that for a string which contains '<b>something</b>' the content is correctly identified by the <b> tag's test function and gets rendered with the appropriate React component. However, since the original string is used for every tag this means the same string will also be handled by the next tag. In this case the <em> tag's test function will evaluate the string, '<b>something</b>' and see that it does not match and herein lies the buggy behavior. When a tag's test function does not get a match for the string it will render it as a fragment and push it to the formatted string array. This means that we get duplicated entries in the formatted string array because we get both the React component version of the string and the fragment version of the string. This buggy behavior is now fixed by passing the result of the first tag operations to the next tag. This ensures that once a part of the original string has been matched and turned into a component it can not be matched again by another tag.
Diffstat (limited to 'scripts/utils/host')
0 files changed, 0 insertions, 0 deletions