Skip to content

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

Closed

Description

@fuenfundachtzig

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 🤷‍♂️)

Activity

  1. github-actions commented on Apr 11, 2024

    @github-actions

    🎉 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: accepting prsPlease, send a pull request to resolve this!type: bugSomething isn't working :(

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions