assertEquals("c", humanishName);
}
+ @Test
+ public void testGetWindowsPathHumanishName()
+ throws IllegalArgumentException,
+ URISyntaxException {
+ if (File.separatorChar == '\\') {
+ String humanishName = new URIish("file:///C\\a\\b\\c.git/")
+ .getHumanishName();
+ assertEquals("c", humanishName);
+ }
+ }
+
@Test
public void testUserPasswordAndPort() throws URISyntaxException {
String str = "http://user:secret@host.xy:80/some/path";
package org.eclipse.jgit.transport;
+import java.io.File;
import java.io.Serializable;
import java.net.URISyntaxException;
import java.net.URL;
public String getHumanishName() throws IllegalArgumentException {
if ("".equals(getPath()) || getPath() == null)
throw new IllegalArgumentException();
- String[] elements = getPath().split("/");
+ String s = getPath();
+ String[] elements;
+ if ("file".equals(scheme) || LOCAL_FILE.matcher(s).matches())
+ elements = s.split("[\\" + File.separatorChar + "/]");
+ else
+ elements = s.split("/");
if (elements.length == 0)
throw new IllegalArgumentException();
String result = elements[elements.length - 1];