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

StringUtils.abbreviate handles empty abbrevMarker #478

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

StringUtils.abbreviate handles empty abbrevMarker #478

wants to merge 2 commits into from

Conversation

jordanjenkins
Copy link

StringUtils.abbreviate would not abbreviate properly when an empty
String was passed to abbrevMarker or abbrevMarker is null
Expected behaviour:
abbreviate("much too long text", "", 13).equals("much too long")
Actual behaviour:
abbreviate("much too long text", "", 13).equals("much too long text")

Behaves the same when abbrevMarker is null.

Added if statements to handle empty and null abbrevMarker
Passed all tests

StringUtils.abbreviate would not abbreviate properly when an empty
String was passed to abbrevMarker or abbrevMarker is null
Expected behaviour:
abbreviate("much too long text", "", 13).equals("much too long")
Actual behaviour:
abbreviate("much too long text", "", 13).equals("much too long text")

Behaves the same when abbrevMarker is null.

Added if statements to handle empty and null abbrevMarker
Passed all tests
'origin/StringUtilsAbbreviateFixed'
@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 95.377% when pulling 050682b on jordanjenkins:StringUtilsAbbreviateFix into 8445d3a on apache:master.

return str;
}

if (abbrevMarker == null){
return str.substring(0, maxWidth + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

StringUtils.abbreviate("a", null, 0, 10);

May throw a StringIndexOutOfBoundsException.

return str.substring(0, maxWidth + 1);
}
if (isEmpty(abbrevMarker)){
return str.substring(0, maxWidth);
Copy link
Contributor

Choose a reason for hiding this comment

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

May throw a StringIndexOutOfBoundsException.

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.

3 participants