Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

package org.springframework.cloud.openfeign;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -122,9 +120,9 @@ static String getUrl(String url) {
url = url.substring(0, url.length() - 1);
}
try {
new URL(url);
new URI(url);
}
catch (MalformedURLException e) {
catch (URISyntaxException e) {
throw new IllegalArgumentException(url + " is malformed", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ private String testGetName(String name) {
return registrar.getName(Collections.singletonMap("name", name));
}

@Test
void goodUrl() {
String url = FeignClientsRegistrar.getUrl("https://good.url");
assertThat(url).as("url was wrong").isEqualTo("https://good.url");
}

@Test
void badUrl() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> FeignClientsRegistrar.getUrl("http://bad url"));
}

@Test
void testRemoveTrailingSlashFromUrl() {
String url = FeignClientsRegistrar.getUrl("http://localhost/");
Expand Down