Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug: \\n -> \n should only happen with template strings #90

Closed
3 tasks done
fuenfundachtzig opened this issue Mar 31, 2024 · 1 comment · Fixed by #91
Closed
3 tasks done

🐛 Bug: \\n -> \n should only happen with template strings #90

fuenfundachtzig opened this issue Mar 31, 2024 · 1 comment · Fixed by #91
Labels
status: accepting prs Please, send a pull request to resolve this! type: bug Something isn't working :(

Comments

@fuenfundachtzig
Copy link
Contributor

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

dedent("\\nu") should return the string unchanged.

Actual

dedent("\\nu") turns the \\n into a newline, i.e. returns a newline character + u.

Additional Info

This happens because result.replace(/\\n/g, "\n") is called regardless of the value of escapeSpecialCharacters, i.e. regardless of whether dedent is called as a tag on a template or as a function on a string.
An easy fix would be to make the replacement conditional, solving this particular problem. (However, it would still not work for dedent`\\nu` because here, still the \\n would be replaced 🤷‍♂️)

@fuenfundachtzig fuenfundachtzig added the type: bug Something isn't working :( label Mar 31, 2024
@JoshuaKGoldberg JoshuaKGoldberg added the status: accepting prs Please, send a pull request to resolve this! label Apr 9, 2024
JoshuaKGoldberg pushed a commit that referenced this issue Apr 10, 2024
… set (#91)

This PR proposes a fix to the issue #90.

## PR Checklist

- [x] Addresses an existing open issue: fixes #90
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/dmnd/dedent/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/dmnd/dedent/blob/main/.github/CONTRIBUTING.md)
were taken
Copy link

🎉 This is included in version v1.5.2 🎉

The release is available on:

Cheers! 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! type: bug Something isn't working :(
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants