Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refs pulse00/Composer-Eclipse-Plugin#20

  • Loading branch information...
commit 4013be3cc5ba565e41dcb90a0ce75d35dc3ab885 1 parent f7581ac
@pulse00 authored
View
3  src/main/java/org/getcomposer/core/packagist/SearchResultDownloader.java
@@ -10,6 +10,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
@@ -29,7 +30,7 @@ public SearchResultDownloader() {
public List<PackageInterface> searchPackages(String query)
throws IOException {
List<PackageInterface> packages = new ArrayList<PackageInterface>();
- setUrl(String.format(ComposerConstants.searchURL, query));
+ setUrl(String.format(ComposerConstants.searchURL, URLEncoder.encode(query, "UTF-8")));
SearchResult result = loadPackages(getUrl());
View
6 src/test/java/org/getcomposer/test/PackagistTest.java
@@ -40,7 +40,7 @@ public void testPackage() {
try {
PackageDownloader downloader = new PackageDownloader("https://packagist.org/packages/react/react.json");
- PHPPackage resource = downloader.getPackage();
+ PHPPackage resource = downloader.getPackage();
assertTrue(resource != null);
assertEquals("react/react", resource.name);
@@ -64,6 +64,7 @@ public void testSearch() {
try {
assertSearchResult("html");
assertSearchResult("react");
+ assertSearchResult("foo bar");
} catch (Exception e) {
e.printStackTrace();
fail();
@@ -79,6 +80,9 @@ protected void assertSearchResult(String query) throws IOException {
assertTrue(packages.size() > 0);
for (PackageInterface phpPackage : packages) {
+ if (query.equals("foo bar")) {
+ System.err.println(phpPackage.getName());
+ }
assertNotNull(phpPackage);
assertNotNull(phpPackage.getName());
assertNotNull(phpPackage.getDescription());
Please sign in to comment.
Something went wrong with that request. Please try again.