Skip to content

Fix #4347: Remove leading and trailing spaces in title #5141

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

Conversation

chan-j-d
Copy link
Contributor

@chan-j-d chan-j-d commented Feb 7, 2023

Description (required)

Fixes #4347

What changes did you make and why?

I updated the removeTrailingWhitespace method to remove both leading and trailing whitespaces. I realized that the issue was partially solved by #5085 and I just had to update the method to also remove leading whitespaces.

The trim method that Java implements only removes chars with codepoint <= 'U+0020' which makes it less general than what is currently desired. The ideal inbuilt method would be strip which is not supported at the current version of SDK so a manual implementation was done similar to what was there before.

Relevant test cases were also updated to include the new requirements.

Tests performed (required)
Tested Build variant: BetaDebug on Pixel XL with API level 30.

Screenshots (for UI changes only)

Need help? See https://support.google.com/android/answer/9075928


Note: Please ensure that you have read CONTRIBUTING.md if this is your first pull request.

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

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

Thanks for adding the ability to remove leading spaces!

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

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

Tested by uploading https://commons.wikimedia.org/wiki/File:Potato_cream_covered_curry_udon_in_Ebisu-Minami.jpg fine spaces at the beginning and end of captions and descriptions, in 3 languages including Japanese. Correctly removes all spaces from all captions and from filename.

@nicolas-raoul nicolas-raoul merged commit f85efeb into commons-app:master Feb 10, 2023
@nicolas-raoul
Copy link
Member

Thanks @chan-j-d, great work!

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.

Remove leading and trailing spaces in title
2 participants