@mintlify/link-rot 3.0.1401 → 3.0.1403

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.
@@ -19,24 +19,37 @@ const isHttpUrl = (url) => {
19
19
  return false;
20
20
  }
21
21
  };
22
- const checkExternalUrl = (url) => __awaiter(void 0, void 0, void 0, function* () {
22
+ const fetchStatus = (url, method) => __awaiter(void 0, void 0, void 0, function* () {
23
+ var _a;
23
24
  const controller = new AbortController();
24
25
  const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
25
26
  try {
26
27
  const response = yield fetch(url, {
27
- method: 'HEAD',
28
+ method,
28
29
  signal: controller.signal,
29
30
  headers: { 'User-Agent': USER_AGENT },
30
31
  redirect: 'follow',
31
32
  });
33
+ yield ((_a = response.body) === null || _a === void 0 ? void 0 : _a.cancel().catch(() => undefined));
34
+ return response.status;
35
+ }
36
+ finally {
32
37
  clearTimeout(timeoutId);
38
+ }
39
+ });
40
+ const HEAD_RETRY_STATUSES = new Set([404, 405]);
41
+ const checkExternalUrl = (url) => __awaiter(void 0, void 0, void 0, function* () {
42
+ try {
43
+ const headStatus = yield fetchStatus(url, 'HEAD');
44
+ const status = HEAD_RETRY_STATUSES.has(headStatus)
45
+ ? yield fetchStatus(url, 'GET').catch(() => headStatus)
46
+ : headStatus;
33
47
  return {
34
- ok: response.status !== 404,
35
- status: response.status,
48
+ ok: status !== 404,
49
+ status,
36
50
  };
37
51
  }
38
52
  catch (err) {
39
- clearTimeout(timeoutId);
40
53
  return {
41
54
  ok: false,
42
55
  status: null,
@@ -11,6 +11,7 @@ import { cleanHeadingId, COMPONENTS_WITH_CLEANED_ID, COMPONENTS_WITHOUT_ID, core
11
11
  import { getMintIgnore } from '@mintlify/prebuild';
12
12
  import fs from 'fs-extra';
13
13
  import path from 'path';
14
+ import remarkSmartypants from 'remark-smartypants';
14
15
  import { visit } from 'unist-util-visit';
15
16
  import { Graph, Wrapper } from '../graph.js';
16
17
  import { getLinkPaths, getPagePaths } from '../prebuild.js';
@@ -94,6 +95,7 @@ export const decorateGraphNodeFromPageContent = (graphNode, content, options) =>
94
95
  };
95
96
  const preprocessed = preprocessCustomHeadingIds(content);
96
97
  const processor = coreRemark()
98
+ .use(remarkSmartypants)
97
99
  .use(visitLinks)
98
100
  .use(remarkComponentIds)
99
101
  .use(remarkExtractTableOfContents, mdxExtracts);