Skip to content

fix(api): correct joinTags space replacement#20643

Closed
Begarudev wants to merge 1 commit intoankidroid:mainfrom
Begarudev:fix/api-join-tags-space-replacement
Closed

fix(api): correct joinTags space replacement#20643
Begarudev wants to merge 1 commit intoankidroid:mainfrom
Begarudev:fix/api-join-tags-space-replacement

Conversation

@Begarudev
Copy link
Copy Markdown

Purpose / Description

Fix Utils.joinTags() so spaces inside a tag are replaced with underscores
before joining.

Fixes

Approach

Use the result of replace() when joining tags, and add a regression test
for tags containing spaces.

How Has This Been Tested?

  • Added a regression test for tags containing spaces
  • :api:testDebugUnitTest

Learning (optional, can help others)

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

joinTags() called replace() but ignored the returned value, so tags with spaces were joined incorrectly. Add a regression test for multi-word tags.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the API module’s Utils.joinTags() helper so that spaces within individual tags are converted to underscores before tags are concatenated into the space-delimited tag string expected by Anki/AnkiDroid.

Changes:

  • Fix Utils.joinTags() to actually use the result of replace() when building the joined tag string.
  • Add a regression unit test covering tags that contain spaces.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
api/src/main/java/com/ichi2/anki/api/Utils.kt Updates joinTags() to replace spaces within each tag before joining.
api/src/test/java/com/ichi2/anki/api/ApiUtilsTest.kt Adds a regression test asserting space-to-underscore escaping for tags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ZornHadNoChoice
Copy link
Copy Markdown
Collaborator

#20630 (comment)

@david-allison
Copy link
Copy Markdown
Member

Missed this. Banned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Utils.joinTags() discards replace result, tags with spaces are not underscore-escaped

4 participants