diff --git a/CHANGELOG.md b/CHANGELOG.md index 3639f9a2..cb2d327e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ * Updated to Realm Core 5.4.0. * Updated to Realm Sync 3.0.0-rc.1. * Tested against Realm Object Server 3.0.0-alpha.8. +* Added `_disablePartialSyncUrlChecks` to `Realm.Configuration`. 2.2.15 Release notes (2018-3-9) ============================================================= diff --git a/lib/index.d.ts b/lib/index.d.ts index 79730398..367ece6f 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -379,6 +379,7 @@ declare namespace Realm.Sync { open_ssl_verify_callback?: SSLVerifyCallback; error?: ErrorCallback; partial?: boolean; + _disablePartialSyncUrlChecks?:boolean; } type ProgressNotificationCallback = (transferred: number, transferable: number) => void; diff --git a/src/js_sync.hpp b/src/js_sync.hpp index 1a3ff6d0..9958c523 100644 --- a/src/js_sync.hpp +++ b/src/js_sync.hpp @@ -823,7 +823,19 @@ void SyncClass::populate_sync_config(ContextType ctx, ObjectType realm_constr is_partial = Value::validated_to_boolean(ctx, partial_value); } - config.sync_config = std::make_shared(shared_user, std::move(raw_realm_url)); + bool disable_partial_sync_url_checks = false; + ValueType disable_partial_sync_url_checks_value = Object::get_property(ctx, sync_config_object, "_disablePartialSyncUrlChecks"); + if (!Value::is_undefined(ctx, disable_partial_sync_url_checks_value)) { + disable_partial_sync_url_checks = Value::validated_to_boolean(ctx, disable_partial_sync_url_checks_value); + } + + if (disable_partial_sync_url_checks) { + config.sync_config = std::make_shared(shared_user, std::move("")); + config.sync_config->reference_realm_url = std::move(raw_realm_url); + } + else { + config.sync_config = std::make_shared(shared_user, std::move(raw_realm_url)); + } config.sync_config->bind_session_handler = std::move(bind); config.sync_config->error_handler = std::move(error_handler); config.sync_config->client_validate_ssl = client_validate_ssl; diff --git a/tests/js/session-tests.js b/tests/js/session-tests.js index 97c8db41..7edc22d1 100644 --- a/tests/js/session-tests.js +++ b/tests/js/session-tests.js @@ -749,6 +749,36 @@ module.exports = { }); }, + testOpenPartialSyncUrl() { + if (!isNodeProccess) { + return; + } + + const username = uuid(); + return Realm.Sync.User.register('http://localhost:9080', username, 'password') + .then(user => { + let config1 = { + sync: { + user: user, + url: `realm://localhost:9080/~/default/__partial/`, + partial: true, + _disablePartialSyncUrlChecks: true + } + }; + const realm = new Realm(config1); + TestCase.assertFalse(realm.isClosed); + + let config2 = { + sync: { + user: user, + url: `realm://localhost:9080/~/default/__partial/`, // <--- not allowed URL + partial: true, + } + }; + TestCase.assertThrows(() => new Realm(config2)); + }); + }, + testPartialSyncAnonymous_SubscriptionListener() { // FIXME: try to enable for React Native if (!isNodeProccess) {