summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/javacs/Urls.java9
-rw-r--r--src/test/java/org/javacs/UrlsTest.java15
2 files changed, 9 insertions, 15 deletions
diff --git a/src/main/java/org/javacs/Urls.java b/src/main/java/org/javacs/Urls.java
index 24c43ea..6ee0f0a 100644
--- a/src/main/java/org/javacs/Urls.java
+++ b/src/main/java/org/javacs/Urls.java
@@ -16,17 +16,14 @@ public final class Urls {
*/
public static URL pathToUrl(String path) {
try {
- if (isSystemPath(path))
- return Paths.get(path).toUri().toURL();
- else
- return new URL(path);
+ if (isSystemPath(path)) return Paths.get(path).toUri().toURL();
+ else return new URL(path);
} catch (MalformedURLException e) {
throw new RuntimeException("Failed to parse path " + path, e);
}
}
private static boolean isSystemPath(String path) {
- return path.startsWith("/") ||
- path.matches("^[a-zA-Z]:[/\\\\].*");
+ return path.startsWith("/") || path.matches("^[a-zA-Z]:[/\\\\].*");
}
}
diff --git a/src/test/java/org/javacs/UrlsTest.java b/src/test/java/org/javacs/UrlsTest.java
index 0e45db3..d94d589 100644
--- a/src/test/java/org/javacs/UrlsTest.java
+++ b/src/test/java/org/javacs/UrlsTest.java
@@ -1,6 +1,5 @@
package org.javacs;
-import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
@@ -8,29 +7,27 @@ import java.net.URL;
import org.junit.Test;
public class UrlsTest {
-
+
@Test
public void pathToUrl_whenPathStartsWithForwardSlash() throws Exception {
URL actual = Urls.pathToUrl("/a/b/c");
assertThat(actual.getProtocol(), equalTo("file"));
}
-
+
@Test
public void pathToUrl_whenPathStartsWithProtocol() throws Exception {
URL actual = Urls.pathToUrl("file:///a/b/c");
assertThat(actual.getProtocol(), equalTo("file"));
}
-
+
@Test
- public void pathToUrl_whenPathStartsWithDriveLetter_usingForwardSlashes()
- throws Exception {
+ public void pathToUrl_whenPathStartsWithDriveLetter_usingForwardSlashes() throws Exception {
URL actual = Urls.pathToUrl("c:/a/b/c");
assertThat(actual.getProtocol(), equalTo("file"));
}
-
+
@Test
- public void pathToUrl_whenPathStartsWithDriveLetter_usingBackslashes()
- throws Exception {
+ public void pathToUrl_whenPathStartsWithDriveLetter_usingBackslashes() throws Exception {
URL actual = Urls.pathToUrl("c:\\a\\b\\c");
assertThat(actual.getProtocol(), equalTo("file"));
}