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

Fix replaceMessage function to handle escaped variables #716

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Aug 14, 2024

Modify the replaceMessage function in src/utils/validateUtil.ts to handle escaped variables and add related test cases.

  • replaceMessage function:

    • Update the replaceMessage function to skip conversion when \${xxx} is passed and convert ${xxx} correctly.
    • Check for the presence of \${xxx} and skip conversion in such cases.
    • Ensure the function correctly converts ${xxx} to the corresponding value from the kv object.
  • validate.test.tsx:

    • Add test cases to verify the correct handling of \${xxx} and ${xxx}.
    • Ensure the test cases cover both scenarios: skipping conversion and converting correctly.
    • Add a new test case to handle escaped and unescaped variables correctly.

For more details, open the Copilot Workspace session.

Modify the `replaceMessage` function in `src/utils/validateUtil.ts` to handle escaped variables and add related test cases.

* **replaceMessage function**:
  - Update the `replaceMessage` function to skip conversion when `\${xxx}` is passed and convert `${xxx}` correctly.
  - Check for the presence of `\${xxx}` and skip conversion in such cases.
  - Ensure the function correctly converts `${xxx}` to the corresponding value from the `kv` object.

* **validate.test.tsx**:
  - Add test cases to verify the correct handling of `\${xxx}` and `${xxx}`.
  - Ensure the test cases cover both scenarios: skipping conversion and converting correctly.
  - Add a new test case to handle escaped and unescaped variables correctly.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/react-component/field-form?shareId=XXXX-XXXX-XXXX-XXXX).
Copy link

vercel bot commented Aug 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
field-form ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 14, 2024 3:05am

Copy link

codecov bot commented Aug 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.44%. Comparing base (ca2f92c) to head (bfa41b8).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #716   +/-   ##
=======================================
  Coverage   99.44%   99.44%           
=======================================
  Files          18       18           
  Lines        1253     1255    +2     
  Branches      308      294   -14     
=======================================
+ Hits         1246     1248    +2     
  Misses          7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Wxh16144
Copy link
Contributor

resolved: ant-design/ant-design#50410

@zombieJ zombieJ merged commit 87e1877 into master Aug 14, 2024
11 checks passed
@zombieJ zombieJ deleted the zombieJ/fix-replace-message branch August 14, 2024 03:21
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.

2 participants