Bug 424712 - Server location needs a slash at the end. r=rnewman
authorMichal Jaskurzynski <mjaskurzynski@gmail.com>
Mon, 12 Nov 2012 09:48:26 -0800
changeset 126445 a090e3ede2e7fc1d58b2ff64f280157f65b99b82
parent 120912 b2bdbfe06b10d57adfd6a4573d07b966c443d17c
child 126446 0b9c66c707ae2442b61e13fbec8c605fd3090c9f
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs424712
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 424712 - Server location needs a slash at the end. r=rnewman
services/sync/modules/service.js
services/sync/tests/unit/test_service_set_serverURL.js
services/sync/tests/unit/xpcshell.ini
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -69,16 +69,20 @@ Sync11Service.prototype = {
   cryptoKeyURL: null,
 
   get enabledEngineNames() {
     return [e.name for each (e in this.engineManager.getEnabled())];
   },
 
   get serverURL() Svc.Prefs.get("serverURL"),
   set serverURL(value) {
+    if (!value.endsWith("/")) {
+      value += "/";
+    }
+
     // Only do work if it's actually changing
     if (value == this.serverURL)
       return;
 
     // A new server most likely uses a different cluster, so clear that
     Svc.Prefs.set("serverURL", value);
     Svc.Prefs.reset("clusterURL");
   },
new file mode 100644
--- /dev/null
+++ b/services/sync/tests/unit/test_service_set_serverURL.js
@@ -0,0 +1,13 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+Cu.import("resource://services-sync/service.js");
+
+function run_test() {
+  Service.serverURL = "http://example.com/sync";
+  do_check_eq(Service.serverURL, "http://example.com/sync/");
+
+  Service.serverURL = "http://example.com/sync/";
+  do_check_eq(Service.serverURL, "http://example.com/sync/");
+}
+
--- a/services/sync/tests/unit/xpcshell.ini
+++ b/services/sync/tests/unit/xpcshell.ini
@@ -62,16 +62,17 @@ skip-if = os == "android"
 [test_service_cluster.js]
 [test_service_createAccount.js]
 [test_service_detect_upgrade.js]
 [test_service_getStorageInfo.js]
 [test_service_login.js]
 [test_service_migratePrefs.js]
 [test_service_passwordUTF8.js]
 [test_service_persistLogin.js]
+[test_service_set_serverURL.js]
 [test_service_startOver.js]
 [test_service_startup.js]
 [test_service_sync_401.js]
 [test_service_sync_locked.js]
 [test_service_sync_remoteSetup.js]
 # Bug 676978: test hangs on Android (see also testing/xpcshell/xpcshell.ini)
 skip-if = os == "android"
 [test_service_sync_updateEnabledEngines.js]