@mintlify/link-rot 3.0.1280 → 3.0.1282

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.
package/dist/graph.js CHANGED
@@ -1,4 +1,4 @@
1
- import { cleanHeadingId, isMintIgnored } from '@mintlify/common';
1
+ import { isMintIgnored, safeCleanHeadingId } from '@mintlify/common';
2
2
  import { getFileListWithDirectories } from '@mintlify/prebuild';
3
3
  import { existsSync } from 'fs';
4
4
  import { parse, join, resolve, relative, dirname, basename } from 'path';
@@ -10,6 +10,16 @@ var PathType;
10
10
  PathType["EXTERNAL"] = "external";
11
11
  PathType["DATA"] = "data";
12
12
  })(PathType || (PathType = {}));
13
+ // URL percent-encodes non-ASCII pathnames, but nodes are keyed by raw filesystem
14
+ // paths, so decode to keep both sides comparable. Malformed escapes stay as-is.
15
+ const decodeUrlComponent = (value) => {
16
+ try {
17
+ return decodeURIComponent(value);
18
+ }
19
+ catch (_a) {
20
+ return value;
21
+ }
22
+ };
13
23
  export var Wrapper;
14
24
  (function (Wrapper) {
15
25
  Wrapper["MD"] = "md";
@@ -60,7 +70,7 @@ export class MdxPath {
60
70
  // resolve relative path
61
71
  // add arbitrary protocol to parse as URL and isolate pathname
62
72
  urlPath = new URL(`mintlify:${normalizedPath}`);
63
- normalizedPath = urlPath.pathname;
73
+ normalizedPath = decodeUrlComponent(urlPath.pathname);
64
74
  // remove trailing slash
65
75
  if (normalizedPath.endsWith('/')) {
66
76
  normalizedPath = normalizedPath.slice(0, -1);
@@ -82,7 +92,11 @@ export class MdxPath {
82
92
  throw new Error(`Failed to parse path as URL: ${this.originalPath}. If this is a purposefully malformed path, please wrap it in backticks, i.e \`${this.originalPath}\` `);
83
93
  }
84
94
  }
85
- const anchorLink = urlPath.hash || undefined;
95
+ const anchorLink = urlPath.hash
96
+ ? pathType === PathType.INTERNAL
97
+ ? decodeUrlComponent(urlPath.hash)
98
+ : urlPath.hash
99
+ : undefined;
86
100
  const queryParams = urlPath.searchParams;
87
101
  return { path, pathType, anchorLink, queryParams };
88
102
  }
@@ -396,7 +410,7 @@ export class Graph {
396
410
  brokenLinks.push(path);
397
411
  }
398
412
  else if ((options === null || options === void 0 ? void 0 : options.checkAnchors) && path.anchorLink) {
399
- const anchor = cleanHeadingId(path.anchorLink.slice(1));
413
+ const anchor = safeCleanHeadingId(path.anchorLink.slice(1));
400
414
  const headingSlugs = this.getHeadingSlugsForPath(pathString, nodeSet);
401
415
  if (headingSlugs && !headingSlugs.has(anchor)) {
402
416
  brokenLinks.push(path);