Skip to content

Commit

Permalink
[FIXED JENKINS-12544] Illegal directory name on Windows when port num…
Browse files Browse the repository at this point in the history
…ber used in URL.
  • Loading branch information
Jesse Glick committed May 1, 2012
1 parent 56cba93 commit fd76cf1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/mercurial/Cache.java
Expand Up @@ -174,7 +174,7 @@ static String hashSource(String source) {
if (!source.endsWith("/")) { if (!source.endsWith("/")) {
source += "/"; source += "/";
} }
Matcher m = Pattern.compile(".+[/]([^/]+)[/]?").matcher(source); Matcher m = Pattern.compile(".+[/]([^/:]+)(:\\d+)?[/]?").matcher(source);
BigInteger hash; BigInteger hash;
try { try {
hash = new BigInteger(1, MessageDigest.getInstance("SHA-1").digest(source.getBytes("UTF-8"))); hash = new BigInteger(1, MessageDigest.getInstance("SHA-1").digest(source.getBytes("UTF-8")));
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/hudson/plugins/mercurial/CacheTest.java
@@ -1,6 +1,7 @@
package hudson.plugins.mercurial; package hudson.plugins.mercurial;


import junit.framework.TestCase; import junit.framework.TestCase;
import org.jvnet.hudson.test.Bug;


public class CacheTest extends TestCase { public class CacheTest extends TestCase {


Expand All @@ -15,4 +16,9 @@ public void testHashSource() throws Exception {
assertEquals("210ED9E2610F74A473985D8D9EF4483D5D30265E-project", Cache.hashSource("ssh://dudette@math.utexas.edu/some/project/")); assertEquals("210ED9E2610F74A473985D8D9EF4483D5D30265E-project", Cache.hashSource("ssh://dudette@math.utexas.edu/some/project/"));
} }


@Bug(12544)
public void testHashSource2() throws Exception {
assertEquals("DA7E6A4632009859A61A551999EE2109EBB69267-ronaldradial", Cache.hashSource("http://ronaldradial:8000/"));
}

} }

0 comments on commit fd76cf1

Please sign in to comment.