Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-11-10 19:51:01 +0000
committerKevin Sawicki2011-11-10 19:51:01 +0000
commit07561a6d08eacc7f17777897d8d2f5c1966a5673 (patch)
tree253c67a9c96107838d5c4e517a89b105d83cff63
parent91449d29fb0c23f688991e7d05596755df0ad15f (diff)
downloadegit-github-07561a6d08eacc7f17777897d8d2f5c1966a5673.tar.gz
egit-github-07561a6d08eacc7f17777897d8d2f5c1966a5673.tar.xz
egit-github-07561a6d08eacc7f17777897d8d2f5c1966a5673.zip
Use file portion instead of entire next page URI
Link headers contain the full host name and therefore prefix checking should be done against the file portion only of the URL. Change-Id: I89444f8edfaf818d393179b9d0328f65cf7ff854 Signed-off-by: Kevin Sawicki <kevin@github.com>
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GitHubClientTest.java3
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java3
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/PageIterator.java12
3 files changed, 16 insertions, 2 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GitHubClientTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GitHubClientTest.java
index 4cd52c48..818d0903 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GitHubClientTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/GitHubClientTest.java
@@ -47,6 +47,7 @@ public class GitHubClientTest {
@Test
public void prefixHostApiV2() {
PrefixClient client = new PrefixClient(IGitHubConstants.HOST_API_V2);
+ assertEquals("/api/v3/repos/o/n", client.uri("/api/v3/repos/o/n"));
assertEquals("/repos/o/n", client.uri("/repos/o/n"));
assertEquals("/api/v2/json/repos/search/test",
client.uri("/api/v2/json/repos/search/test"));
@@ -58,6 +59,7 @@ public class GitHubClientTest {
@Test
public void prefixHostApiV3() {
PrefixClient client = new PrefixClient(IGitHubConstants.HOST_API);
+ assertEquals("/api/v3/repos/o/n", client.uri("/api/v3/repos/o/n"));
assertEquals("/repos/o/n", client.uri("/repos/o/n"));
assertEquals("/api/v2/json/repos/search/test",
client.uri("/api/v2/json/repos/search/test"));
@@ -70,6 +72,7 @@ public class GitHubClientTest {
public void prefixLocalhost() {
PrefixClient client = new PrefixClient("localhost");
assertEquals("/api/v3/repos/o/n", client.uri("/repos/o/n"));
+ assertEquals("/api/v3/repos/o/n", client.uri("/api/v3/repos/o/n"));
assertEquals("/api/v2/json/repos/search/test",
client.uri("/api/v2/json/repos/search/test"));
}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
index 0fc435d1..331426f7 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
@@ -216,7 +216,8 @@ public class GitHubClient {
* @return configured URI
*/
protected String configureUri(final String uri) {
- if (prefix == null || uri.startsWith(SEGMENT_V2_API))
+ if (prefix == null || uri.startsWith(SEGMENT_V2_API)
+ || uri.startsWith(prefix))
return uri;
return prefix + uri;
}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/PageIterator.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/PageIterator.java
index d74f18ea..20f7a574 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/PageIterator.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/PageIterator.java
@@ -13,8 +13,10 @@ package org.eclipse.egit.github.core.client;
import static org.eclipse.egit.github.core.client.IGitHubConstants.PARAM_PAGE;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -154,7 +156,15 @@ public class PageIterator<V> implements Iterator<Collection<V>>,
if (!hasNext())
throw new NoSuchElementException();
if (next != null)
- request.setUri(next);
+ if (nextPage < 1)
+ request.setUri(next);
+ else
+ try {
+ request.setUri(new URL(next).getFile());
+ } catch (MalformedURLException e) {
+ request.setUri(next);
+ }
+
GitHubResponse response;
try {
response = client.get(request);

Back to the top