Use regex instead of simple substring (#2075)
This commit is contained in:
parent
142c626e4f
commit
7cc4e0feee
|
@ -5,7 +5,7 @@ x.x.x Release notes (yyyy-MM-dd)
|
|||
|
||||
### Fixed
|
||||
* <How to hit and notice issue? what was the impact?> ([#????](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.
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue