Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -676,7 +676,7 @@ private static URL parseURL(String encodedUrl) {
try {
return new URL(encodedUrl);
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
throw new IllegalArgumentException("Malformed URL: \"" + encodedUrl + "\"", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

package com.google.api.client.http;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

import com.google.api.client.util.Key;
import java.net.MalformedURLException;
import java.net.URI;
Expand Down Expand Up @@ -98,6 +101,15 @@ public void testParse_noPath() {
assertNull(url.getPathParts());
}

public void testParse_malformedUrl() {
try {
new GenericUrl("http://example.com:8080http://example.com:8080/");
fail("expected " + IllegalArgumentException.class);
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), equalTo("Malformed URL: \"http://example.com:8080http://example.com:8080/\""));
}
}

private static final String SHORT_PATH = "http://bar/path?a=b";

private static final List<String> SHORT_PATH_PARTS = Arrays.asList("", "path");
Expand Down