fetchurl-sdk 0.1.5 → 0.1.6

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.
Files changed (2) hide show
  1. package/fetchurl.js +16 -0
  2. package/package.json +5 -2
package/fetchurl.js CHANGED
@@ -63,6 +63,13 @@ export class PartialWriteError extends FetchUrlError {
63
63
  }
64
64
  }
65
65
 
66
+ export class MissingSourceUrlsError extends FetchUrlError {
67
+ constructor() {
68
+ super('sourceUrls is required');
69
+ this.name = 'MissingSourceUrlsError';
70
+ }
71
+ }
72
+
66
73
  // --- Algorithm helpers ---
67
74
 
68
75
  /** Map from normalized algo name to Web Crypto algorithm identifier. */
@@ -109,6 +116,11 @@ export function encodeSourceUrls(urls) {
109
116
  * @returns {string[]}
110
117
  */
111
118
  export function parseFetchurlServer(value) {
119
+ value = value.trim();
120
+ if (value === '') return [];
121
+ if (!value.startsWith('"')) {
122
+ return [value];
123
+ }
112
124
  const results = [];
113
125
  let i = 0;
114
126
  while (i < value.length) {
@@ -267,6 +279,10 @@ export class FetchSession {
267
279
  servers = parseFetchurlServer(process.env.FETCHURL_SERVER || '');
268
280
  }
269
281
 
282
+ if (!Array.isArray(sourceUrls) || sourceUrls.length === 0) {
283
+ throw new MissingSourceUrlsError();
284
+ }
285
+
270
286
  this.#algo = normalizeAlgo(algo);
271
287
  if (!isSupported(this.#algo)) {
272
288
  throw new UnsupportedAlgorithmError(this.#algo);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fetchurl-sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Protocol-level client SDK for fetchurl content-addressable cache servers",
5
5
  "type": "module",
6
6
  "exports": "./fetchurl.js",
@@ -22,5 +22,8 @@
22
22
  "url": "git+https://github.com/lucasew/fetchurl.git",
23
23
  "directory": "sdk/js"
24
24
  },
25
- "homepage": "https://github.com/lucasew/fetchurl"
25
+ "homepage": "https://github.com/lucasew/fetchurl",
26
+ "devDependencies": {
27
+ "testcontainers": "^10.6.0"
28
+ }
26
29
  }