@thallylabs/migrate 0.2.35 → 0.2.37

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/index.js CHANGED
@@ -15412,7 +15412,7 @@ function validateUrlMigration(checkpoint, cancelled = false) {
15412
15412
  } catch {
15413
15413
  }
15414
15414
  if (!destination.evidence?.anchors.includes(anchor)) {
15415
- warnings.push({ code: "source-link-warning", source: record.url, message: `The original source link refers to an absent source anchor: ${link}` });
15415
+ warnings.push({ code: "source-link-warning", source: record.url, message: `The original source link refers to an absent source anchor; the imported link opens the page instead: ${link}` });
15416
15416
  } else if (destination.page) {
15417
15417
  const nodes = markdownNodes(destination.page.body);
15418
15418
  const explicit = nodes.flatMap((node) => node.name === "a" ? (node.attributes ?? []).flatMap((attribute) => attribute.name === "id" && typeof attribute.value === "string" ? [attribute.value] : []) : []);
@@ -15861,8 +15861,17 @@ ${difference}`;
15861
15861
  } catch {
15862
15862
  return value;
15863
15863
  }
15864
- const route = routeMap.get(canonical(url.toString(), sourceUrl));
15865
- return route ? `${route}${url.hash}` : value;
15864
+ const identity = canonical(url.toString(), sourceUrl);
15865
+ const route = routeMap.get(identity);
15866
+ if (!route) return value;
15867
+ const destination = resolveMigrationRecord(records, records.get(identity));
15868
+ let anchor = url.hash.slice(1);
15869
+ try {
15870
+ anchor = decodeURIComponent(anchor);
15871
+ } catch {
15872
+ }
15873
+ const hasBrokenSourceAnchor = Boolean(url.hash && destination?.outcome === "imported" && destination.evidence && !destination.evidence.anchors.includes(anchor));
15874
+ return `${route}${hasBrokenSourceAnchor ? "" : url.hash}`;
15866
15875
  }) }] : []);
15867
15876
  const validation = validateUrlMigration(checkpoint, Boolean(options.signal?.aborted));
15868
15877
  validation.issues.push(...navigationIssues);