mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-03 23:25:52 +00:00
Added a convenience method.
This change is originally from pull request #682.
This commit is contained in:
1 parent
902edc38aa
commit
00bfa35651
2 files changed
+20
-2
No files matched your search
@@ -513,6 +513,25 @@ public class Util {
|
||||
else return s;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ensure string ends with suffix
|
||||
*
|
||||
* @param subject Examined string
|
||||
* @param suffix Desired suffix
|
||||
* @return Original subject in case it already ends with suffix, null in
|
||||
* case subject was null and subject + suffix otherwise.
|
||||
* @since 1.505
|
||||
*/
|
||||
public static String ensureEndsWith(String subject, String suffix) {
|
||||
|
||||
if (subject == null) return null;
|
||||
|
||||
if (subject.endsWith(suffix)) return subject;
|
||||
|
||||
return subject + suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes MD5 digest of the given input stream.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user