Invisible Character Bugs
This week I ran into a surprisingly interesting bug while working on a feature that generates diffs for history changes in comments, decription. The Setup We have a system that tracks history chang...

Source: DEV Community
This week I ran into a surprisingly interesting bug while working on a feature that generates diffs for history changes in comments, decription. The Setup We have a system that tracks history changes in backend. Whenever there’s a modification, we generate a diff and send both the old and new values to the frontend. The initial content follows a simple template: Task {id}: Working on abc\n Data: {data}\n If anything changes, the diff should reflect it clearly. The Problem While testing, I noticed something odd. Even when no changes were made—just clicking the Save button for first time in FE —the system still generated a diff. The frontend showed differences between the "old" and "new" values, even though the text looked identical. At first, I checked the strings using console logs. Everything appeared normal. No visible differences. After spending some time debugging, I copied the API response and inspected it more closely. That’s when I noticed the issue: The old version used \n (LF