(category, name, applicationId)
| 98 | }; |
| 99 | |
| 100 | function getStore(category, name, applicationId) { |
| 101 | const invalidNameRegex = /['"`]/; |
| 102 | if (invalidNameRegex.test(name)) { |
| 103 | // Prevent a malicious user from injecting properties into the store |
| 104 | return createStore(); |
| 105 | } |
| 106 | |
| 107 | const path = name.split('.'); |
| 108 | path.splice(-1); // remove last component |
| 109 | applicationId = applicationId || Parse.applicationId; |
| 110 | _triggerStore[applicationId] = _triggerStore[applicationId] || baseStore(); |
| 111 | let store = _triggerStore[applicationId][category]; |
| 112 | for (const component of path) { |
| 113 | if (!Object.prototype.hasOwnProperty.call(store, component)) { |
| 114 | return createStore(); |
| 115 | } |
| 116 | store = store[component]; |
| 117 | if (!store || Object.getPrototypeOf(store) !== null) { |
| 118 | return createStore(); |
| 119 | } |
| 120 | } |
| 121 | return store; |
| 122 | } |
| 123 | |
| 124 | function add(category, name, handler, applicationId) { |
| 125 | const lastComponent = name.split('.').splice(-1); |
no test coverage detected