Skip to content

Commit

Permalink
[FIXED JENKINS-27974]: Use StringUtils.isBlank and add javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ydubreuil committed Apr 21, 2015
1 parent 07deb07 commit c2dfcab
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/hudson/tasks/test/TestObject.java
Expand Up @@ -32,6 +32,7 @@
import hudson.tasks.junit.TestResultAction;
import jenkins.model.Jenkins;

import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.*;
import org.kohsuke.stapler.export.ExportedBean;

Expand Down Expand Up @@ -371,17 +372,19 @@ protected final String uniquifyName(Collection<? extends TestObject> siblings, S

/**
* Replaces URL-unsafe characters.
*
* If s is an empty string, returns "(empty)" otherwise the generated URL would contain
* two slashes one after the other and getDynamic() would fail
*/
public static String safe(String s) {
if (s.isEmpty()) {
if (StringUtils.isEmpty(s)) {
return "(empty)";
} else {
// this still seems to be a bit faster than a single replace with regexp
return s.replace('/', '_').replace('\\', '_').replace(':', '_').replace('?', '_').replace('#', '_').replace('%', '_');
// Note: we probably should some helpers like Commons URIEscapeUtils here to escape all invalid URL chars, but then we
// still would have to escape /, ? and so on
}

// Note: we probably should some helpers like Commons URIEscapeUtils here to escape all invalid URL chars, but then we
// still would have to escape /, ? and so on
}

/**
Expand Down

0 comments on commit c2dfcab

Please sign in to comment.