solomax commented on code in PR #1504:
URL: https://github.com/apache/wicket/pull/1504#discussion_r3526580373
##########
wicket-core/src/main/java/org/apache/wicket/core/util/string/JavaScriptUtils.java:
##########
@@ -95,6 +95,29 @@ public static CharSequence escapeQuotesAndBackslash(final
CharSequence input)
return s;
}
+ /**
+ * Removes the surrounding single quotes from a string after trimming
+ * leading and trailing whitespace.
+ *
+ * <p>Examples:</p>
+ * <pre>
+ * unquoteSingleQuoted(" 'url' ") -> "url"
+ * unquoteSingleQuoted("'url'") -> "url"
+ * unquoteSingleQuoted("''") -> ""
+ * </pre>
+ *
+ * @param s the single-quoted string
+ * @return the contents between the outer single quotes
+ */
+ public static String unquoteSingleQuoted(String s)
+ {
+ if (s != null && s.trim().startsWith("'") &&
s.trim().endsWith("'"))
Review Comment:
`trim()` is used 3 times, maybe it's better to introduce variable for
trimmed string?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]