Skip to content

Commit

Permalink
Trivial tweak for replaceEscapes
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellansun committed Jan 11, 2025
1 parent e3491f5 commit 7c7e0ec
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ public class StringUtils {
public static final int DOLLAR_SLASHY = 2;

public static String replaceEscapes(String text, int slashyType) {
if (slashyType == SLASHY || slashyType == DOLLAR_SLASHY) {
text = StringUtils.replaceHexEscapes(text);
text = StringUtils.replaceLineEscape(text);
if (slashyType == NONE_SLASHY) {
text = replaceEscapes(text);
} else if (slashyType == SLASHY || slashyType == DOLLAR_SLASHY) {
text = replaceHexEscapes(text);
text = replaceLineEscape(text);

if (slashyType == SLASHY) {
text = replace(text,"\\/", "/");
} else if (slashyType == DOLLAR_SLASHY) {
text = replace(text,"$/", "/");
text = replace(text,"$$", "$");
}
} else if (slashyType == NONE_SLASHY) {
text = StringUtils.replaceEscapes(text);
} else {
} else {
throw new IllegalArgumentException("Invalid slashyType: " + slashyType);
}

Expand Down Expand Up @@ -160,8 +160,8 @@ public static boolean isEmpty(final CharSequence cs) {
private static String replaceEscapes(String text) {
if (!text.contains(BACKSLASH)) return text;
text = replace(text,"\\$", "$");
text = StringUtils.replaceLineEscape(text);
return StringUtils.replaceStandardEscapes(replaceHexEscapes(replaceOctalEscapes(text)));
text = replaceLineEscape(text);
return replaceStandardEscapes(replaceHexEscapes(replaceOctalEscapes(text)));
}

private static String replaceLineEscape(String text) {
Expand Down

0 comments on commit 7c7e0ec

Please sign in to comment.