vet-sdk-core-ts 0.4.27 → 0.4.28

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.
@@ -82,16 +82,29 @@ function extractIndexProjection(bundle, policy) {
82
82
  continue;
83
83
  if (typeof entry.fullUrl !== 'string')
84
84
  throw new Error('Each indexed resource requires an absolute HTTPS fullUrl');
85
- let parsed;
86
- try {
87
- parsed = new URL(entry.fullUrl);
85
+ const relative = /^([A-Z][A-Za-z0-9]+)\/([0-9a-f-]+)$/i.exec(entry.fullUrl);
86
+ let urlResourceType;
87
+ let urlId;
88
+ if (relative) {
89
+ ;
90
+ [, urlResourceType, urlId] = relative;
88
91
  }
89
- catch {
90
- throw new Error('Each indexed resource requires an absolute HTTPS fullUrl');
92
+ else {
93
+ let parsed;
94
+ try {
95
+ parsed = new URL(entry.fullUrl);
96
+ }
97
+ catch {
98
+ throw new Error('The index fullUrl must contain /<ResourceType>/<UUID>');
99
+ }
100
+ if (parsed.protocol !== 'https:')
101
+ throw new Error('The index fullUrl must contain /<ResourceType>/<UUID>');
102
+ const segments = parsed.pathname.split('/').filter(Boolean);
103
+ urlResourceType = segments.at(-2);
104
+ urlId = segments.at(-1);
91
105
  }
92
- const segments = parsed.pathname.split('/').filter(Boolean);
93
- if (parsed.protocol !== 'https:' || segments.at(-2) !== resource.resourceType
94
- || segments.at(-1) !== resource.id || !UUID_PATTERN.test(resource.id)) {
106
+ if (urlResourceType !== resource.resourceType
107
+ || urlId !== resource.id || !UUID_PATTERN.test(resource.id)) {
95
108
  throw new Error('The fullUrl must end in /<ResourceType>/<UUID> matching the resource');
96
109
  }
97
110
  if (resource.resourceType === 'Binary' && resource.contentType === 'application/pdf') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vet-sdk-core-ts",
3
- "version": "0.4.27",
3
+ "version": "0.4.28",
4
4
  "description": "Browser-safe VetChain core contracts and governed animal species identifiers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Connecting Solution & Applications Ltd",