MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / resolveLinkPathSync

Function resolveLinkPathSync

src/editor/TaskLinkOverlay.ts:559–590  ·  view source on GitHub ↗
(
	linkPath: string,
	sourcePath: string,
	plugin: TaskNotesPlugin
)

Source from the content-addressed store, hash-verified

557}
558
559function resolveLinkPathSync(
560 linkPath: string,
561 sourcePath: string,
562 plugin: TaskNotesPlugin
563): string | null {
564 // Validate inputs
565 if (!linkPath || typeof linkPath !== "string" || linkPath.trim().length === 0) {
566 return null;
567 }
568
569 if (!sourcePath || typeof sourcePath !== "string") {
570 return null;
571 }
572
573 if (!plugin || !plugin.app || !plugin.app.metadataCache) {
574 return null;
575 }
576
577 try {
578 // Use Obsidian's API to resolve the link path - it handles relative paths safely
579 const file = plugin.app.metadataCache.getFirstLinkpathDest(linkPath, sourcePath);
580
581 // Validate result
582 if (!file || !file.path || typeof file.path !== "string") {
583 return null;
584 }
585
586 return file.path;
587 } catch {
588 return null;
589 }
590}
591
592function getTaskInfoSync(filePath: string, plugin: TaskNotesPlugin): TaskInfo | null {
593 // Validate inputs

Callers 1

buildTaskLinkDecorationsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected