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

support unescaping forward slash #1548

Merged
merged 1 commit into from
Aug 26, 2022
Merged

Conversation

amagee-willow
Copy link
Contributor

Adds support for unescaping the / character. This is one of the characters that i18next itself escapes so I think this is a must.

This fixes #1487 which is closed but not fixed.

Note I have only handled exactly &#x2F, case sensitively. This is what i18next's escaper produces so it's enough to fix the issue. Handling case insensitivity would be a further improvement, though this applies to some of the existing codes too. It's not completely trivial. For example, some entities support all-lowercase and all-uppercase versions but not mixtures, and some only support lowercase. For example, & and & are both valid versions of the ampersand, but &aMp; is not. However for ellipsis, only … is supported, … is not. The numeric codes like &#x2F appear to support any mixture of case.

Checklist

  • only relevant code is changed (make a diff before you submit the PR)
  • run tests npm run test
  • tests are included
  • commit message and code follows the Developer's Certification of Origin

Checklist (for documentation change)

  • only relevant documentation part is changed (make a diff before you submit the PR)
  • motivation/reason is provided
  • commit message and code follows the Developer's Certification of Origin

@coveralls
Copy link

Coverage Status

Coverage remained the same at 95.862% when pulling c6cfd9a on amagee-willow:master into db9ba28 on i18next:master.

@adrai adrai merged commit 052784d into i18next:master Aug 26, 2022
adrai added a commit that referenced this pull request Aug 26, 2022
@adrai
Copy link
Member

adrai commented Aug 26, 2022

Thank you. It's included in v11.18.5

@npearson72
Copy link

@adrai and @amagee I'm on 11.18.6 and still seeing the issue. Is there a special trick to this? Here's what I have:

        <Trans
          t={t}
          i18nKey="paragraph2"
          values={{ phone: '(800) 555-1212', url: 'https://example.com' }}
        >
          <Anchor href={`tel:${'(800) 555-1212'}`} target="new" />
          <Anchor href="https://example.com" target="new" />
        </Trans>

My url gets displayed like so: https:&#x2F;&#x2F;example.com

@adrai
Copy link
Member

adrai commented Dec 30, 2022

@adrai and @amagee I'm on 11.18.6 and still seeing the issue. Is there a special trick to this? Here's what I have:

        <Trans
          t={t}
          i18nKey="paragraph2"
          values={{ phone: '(800) 555-1212', url: 'https://example.com' }}
        >
          <Anchor href={`tel:${'(800) 555-1212'}`} target="new" />
          <Anchor href="https://example.com" target="new" />
        </Trans>

My url gets displayed like so: https:&#x2F;&#x2F;example.com

@npearson72 please create a reproducible example... seems to work here: https://codesandbox.io/s/react-i18next-http-example-forked-svfc2x?file=/src/app.js:995-1254

@npearson72
Copy link

@adrai I found my issue. I was missing this:

    interpolation: {
      escapeValue: false
    }

Thank you buddy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trans component's shouldUnescape does not unescape forward slash
5 participants