Skip to content

Commit f461b5c

Browse files
committed
For open source Parse with /parse mounts, this fix helps avoid the problem of remembering to add
the trailing slash.
1 parent 036b0cb commit f461b5c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Parse/src/main/java/com/parse/Parse.java

+7
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ public Builder clientKey(String clientKey) {
142142
* @return The same builder, for easy chaining.
143143
*/
144144
public Builder server(String server) {
145+
146+
// Add an extra trailing slash so that Parse REST commands include
147+
// the path as part of the server URL (i.e. http://api.myhost.com/parse)
148+
if (server.charAt(server.length() - 1) != '/') {
149+
server = server + "/";
150+
}
151+
145152
this.server = server;
146153
return this;
147154
}

Parse/src/test/java/com/parse/ParseClientConfigurationTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public void testBuilder() {
3030
Parse.Configuration.Builder builder = new Parse.Configuration.Builder(null);
3131
builder.applicationId("foo");
3232
builder.clientKey("bar");
33-
builder.server("some.server");
33+
builder.server("http://myserver.com/parse");
3434
builder.enableLocalDataStore();
3535
Parse.Configuration configuration = builder.build();
3636

3737
assertNull(configuration.context);
3838
assertEquals(configuration.applicationId, "foo");
3939
assertEquals(configuration.clientKey, "bar");
40-
assertEquals(configuration.server, "some.server");
40+
assertEquals(configuration.server, "http://myserver.com/parse/");
4141
assertEquals(configuration.localDataStoreEnabled, true);
4242
}
4343

0 commit comments

Comments
 (0)