Skip to content

For open source Parse with /parse mounts, this fix helps avoid the problem of remembering to add the trailing slash. #436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2016
Merged
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
7 changes: 7 additions & 0 deletions Parse/src/main/java/com/parse/Parse.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ public Builder clientKey(String clientKey) {
* @return The same builder, for easy chaining.
*/
public Builder server(String server) {

// Add an extra trailing slash so that Parse REST commands include
// the path as part of the server URL (i.e. http://api.myhost.com/parse)
if (server.endsWith("/") == false) {
server = server + "/";
}

this.server = server;
return this;
}
Expand Down
18 changes: 16 additions & 2 deletions Parse/src/test/java/com/parse/ParseClientConfigurationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,31 @@ public void testBuilder() {
Parse.Configuration.Builder builder = new Parse.Configuration.Builder(null);
builder.applicationId("foo");
builder.clientKey("bar");
builder.server("some.server");
builder.enableLocalDataStore();
Parse.Configuration configuration = builder.build();

assertNull(configuration.context);
assertEquals(configuration.applicationId, "foo");
assertEquals(configuration.clientKey, "bar");
assertEquals(configuration.server, "some.server");
assertEquals(configuration.localDataStoreEnabled, true);
}

@Test
public void testBuilderServerURL() {
Parse.Configuration.Builder builder = new Parse.Configuration.Builder(null);
builder.server("http://myserver.com/parse/");
Parse.Configuration configuration = builder.build();
assertEquals(configuration.server, "http://myserver.com/parse/");
}

@Test
public void testBuilderServerMissingSlashURL() {
Parse.Configuration.Builder builder = new Parse.Configuration.Builder(null);
builder.server("http://myserver.com/missingslash");
Parse.Configuration configuration = builder.build();
assertEquals(configuration.server, "http://myserver.com/missingslash/");
}

@Test
public void testNetworkInterceptors() {
ParseNetworkInterceptor interceptorA = mock(ParseNetworkInterceptor.class);
Expand Down