diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dc3fc0d..ad6e9ee4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ x.x.x Release notes (yyyy-MM-dd) ### Fixed * ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?) -* None. +* Fixed an incorrect property named returned from `Realm.subscriptions()`. (since v2.19.0-rc.2) ### Compatibility * Realm Object Server: 3.11.0 or later. diff --git a/lib/extensions.js b/lib/extensions.js index 0e40865e..628d250e 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -27,6 +27,8 @@ let getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function(obj }, {}); }; +const subscriptionObjectNameRegex = /^(class_)?(.*?)(_matches)?$/gm; + function setConstructorOnPrototype(klass) { if (klass.prototype.constructor !== klass) { Object.defineProperty(klass.prototype, 'constructor', { value: klass, configurable: true, writable: true }); @@ -393,7 +395,7 @@ module.exports = function(realmConstructor) { let matches_property = subscription['matches_property']; let sub = { name: subscription['name'], - objectType: matches_property.substr(0, matches_property.length-8), // remove _matches + objectType: matches_property.replace(subscriptionObjectNameRegex, '$2'), query: subscription['query'], } listOfSubscriptions.push(sub);