@lde/distribution-probe 0.1.8 → 0.1.10

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/dist/probe.js +22 -7
  2. package/package.json +2 -2
package/dist/probe.js CHANGED
@@ -293,12 +293,12 @@ async function probeDataDump(url, distribution, options, authHeaders, start) {
293
293
  : null;
294
294
  const responseTimeMs = Math.round(performance.now() - start);
295
295
  const result = new DataDumpProbeResult(url, getResponse, responseTimeMs, failureReason);
296
- checkContentTypeMismatch(result, distribution.mimeType);
296
+ checkContentTypeMismatch(result, distribution);
297
297
  return result;
298
298
  }
299
299
  const responseTimeMs = Math.round(performance.now() - start);
300
300
  const result = new DataDumpProbeResult(url, headResponse, responseTimeMs);
301
- checkContentTypeMismatch(result, distribution.mimeType);
301
+ checkContentTypeMismatch(result, distribution);
302
302
  return result;
303
303
  }
304
304
  // The RDF serializations whose bodies we parse to confirm they carry triples. A
@@ -383,16 +383,31 @@ function isRemoteContextError(error) {
383
383
  return /remote context/i.test(error.message);
384
384
  }
385
385
  /**
386
- * Compare the declared MIME type from the dataset registry against the
386
+ * Compare the declared media type from the dataset registry against the
387
387
  * server's Content-Type header. Adds a warning when they disagree.
388
+ *
389
+ * The declared compressed form (e.g. `application/n-quads+gzip`) is the expected
390
+ * answer for a `+gzip`/`+zip` distribution, since the body is a gzip/zip archive
391
+ * served as-is. The bare media type (`application/n-quads`) is also accepted as a
392
+ * lenient fallback — the RDF serialization is the same and only the compression
393
+ * wrapper is absent — so a server that serves the uncompressed representation is
394
+ * not flagged. A different compression suffix or a different base serialization is
395
+ * still a genuine mismatch. The registry strips the suffix into a separate compress
396
+ * format on ingest, so comparing against {@link Distribution.mimeType} alone would
397
+ * false-positive every compressed distribution.
388
398
  */
389
- function checkContentTypeMismatch(result, declaredMimeType) {
390
- if (!result.isSuccess() || !declaredMimeType || !result.contentType)
399
+ function checkContentTypeMismatch(result, distribution) {
400
+ const { mimeType } = distribution;
401
+ if (!result.isSuccess() || !mimeType || !result.contentType)
391
402
  return;
392
403
  const actual = result.contentType.split(';')[0].trim();
393
404
  if (compressionMediaTypes.has(actual))
394
405
  return;
395
- if (actual !== declaredMimeType) {
396
- result.warnings.push(`Server Content-Type ${actual} does not match declared media type ${declaredMimeType}`);
406
+ const acceptable = distribution.compressedMimeType === undefined
407
+ ? [mimeType]
408
+ : [mimeType, distribution.compressedMimeType];
409
+ if (!acceptable.includes(actual)) {
410
+ const expected = distribution.compressedMimeType ?? mimeType;
411
+ result.warnings.push(`Server Content-Type ${actual} does not match declared media type ${expected}`);
397
412
  }
398
413
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/distribution-probe",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "repository": {
5
5
  "url": "git+https://github.com/ldelements/lde.git",
6
6
  "directory": "packages/distribution-probe"
@@ -24,7 +24,7 @@
24
24
  "!**/*.tsbuildinfo"
25
25
  ],
26
26
  "dependencies": {
27
- "@lde/dataset": "0.7.5",
27
+ "@lde/dataset": "0.7.7",
28
28
  "rdf-parse": "^5.0.0",
29
29
  "tslib": "^2.3.0"
30
30
  }