@livequery/nestjs 1.0.47 → 1.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,6 @@ const const_1 = require("../const");
|
|
|
5
5
|
class PathHelper {
|
|
6
6
|
static trimLivequeryHotkey(path) {
|
|
7
7
|
const ref = path
|
|
8
|
-
?.split('~')[0]
|
|
9
8
|
?.replaceAll(':', '')
|
|
10
9
|
?.split(const_1.LIVEQUERY_MAGIC_KEY)?.[1]
|
|
11
10
|
?.split('/')
|
|
@@ -17,18 +16,19 @@ class PathHelper {
|
|
|
17
16
|
}
|
|
18
17
|
static parseHttpRequestPath(path) {
|
|
19
18
|
const refs = path
|
|
20
|
-
?.split('~')[0]
|
|
21
19
|
?.replaceAll(':', '')
|
|
22
20
|
?.split(const_1.LIVEQUERY_MAGIC_KEY)?.[1]
|
|
23
21
|
?.split('/')
|
|
24
22
|
?.filter(s => s.length > 0);
|
|
25
23
|
if (!refs)
|
|
26
24
|
throw 'LIVEQUERY_MAGIC_KEY_NOT_FOUND';
|
|
27
|
-
const is_collection = refs.length % 2 == 1;
|
|
28
25
|
const ref = refs.join('/');
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
26
|
+
const ref_without_action = ref.split('/~')[0];
|
|
27
|
+
const refs_without_action = ref_without_action.split('/');
|
|
28
|
+
const is_collection = refs_without_action.length % 2 == 1;
|
|
29
|
+
const collection_ref = is_collection ? ref_without_action : refs_without_action.slice(0, refs_without_action.length - 1).join('/');
|
|
30
|
+
const schema_ref = refs_without_action.filter((_, i) => i % 2 == 0).join('/');
|
|
31
|
+
const doc_id = is_collection ? null : refs_without_action[refs_without_action.length - 1];
|
|
32
32
|
return { ref, schema_ref, is_collection, doc_id, collection_ref };
|
|
33
33
|
}
|
|
34
34
|
static join(a, b) {
|