mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-24 05:31:33 +00:00
simplify port/scheme check
This commit is contained in:
@@ -160,12 +160,11 @@ public class CheckHostTrustController implements FxController {
|
||||
}
|
||||
|
||||
public static String getAuthority(URI uri) {
|
||||
return switch (uri.getPort()) {
|
||||
case -1 -> "%s://%s".formatted(uri.getScheme(), uri.getHost());
|
||||
case 80 -> "http://%s".formatted(uri.getHost());
|
||||
case 443 -> "https://%s".formatted(uri.getHost());
|
||||
default -> "%s://%s:%s".formatted(uri.getScheme(), uri.getHost(), uri.getPort());
|
||||
};
|
||||
if (uri.getPort() == -1) {
|
||||
return "%s://%s".formatted(uri.getScheme(), uri.getHost());
|
||||
} else {
|
||||
return "%s://%s:%s".formatted(uri.getScheme(), uri.getHost(), uri.getPort());
|
||||
}
|
||||
}
|
||||
|
||||
//--- JavaFX property getter & setter
|
||||
|
||||
@@ -34,8 +34,8 @@ class CheckHostTrustControllerTest {
|
||||
"https://example.com/foo/bar, https://example.com",
|
||||
"https://example.com:8080, https://example.com:8080",
|
||||
"https://user@example.com:8080/foo/bar, https://example.com:8080",
|
||||
"https://user@example.com:443/foo/bar, https://example.com",
|
||||
"http://user@example.com:80/foo/bar?foo=bar, http://example.com",
|
||||
"https://user@example.com:443/foo/bar, https://example.com:443",
|
||||
"http://user@example.com:80/foo/bar?foo=bar, http://example.com:80",
|
||||
"http://user@example.com:8080/foo/bar?foo=bar, http://example.com:8080"
|
||||
})
|
||||
void testGetAuthority(String input, String expected) {
|
||||
|
||||
Reference in New Issue
Block a user