MCPcopy
hub / github.com/callumalpass/tasknotes / parseProjectFilePath

Function parseProjectFilePath

src/utils/folderTemplateProcessor.ts:113–146  ·  view source on GitHub ↗
(project: string)

Source from the content-addressed store, hash-verified

111}
112
113function parseProjectFilePath(project: string): string {
114 const trimmed = project.trim();
115 if (!trimmed) {
116 return "";
117 }
118
119 if (trimmed.startsWith("[[") && trimmed.endsWith("]]")) {
120 const linkContent = trimmed.slice(2, -2).trim();
121 const pipeIndex = linkContent.indexOf("|");
122 const path = pipeIndex !== -1 ? linkContent.slice(0, pipeIndex) : linkContent;
123 return stripMarkdownExtension(path.trim());
124 }
125
126 const markdownMatch = trimmed.match(/^\[[^\]]*\]\(([^)]+)\)$/);
127 if (markdownMatch) {
128 let linkPath = markdownMatch[1].trim();
129 if (linkPath.startsWith("<") && linkPath.endsWith(">")) {
130 linkPath = linkPath.slice(1, -1).trim();
131 }
132 try {
133 linkPath = decodeURIComponent(linkPath);
134 } catch (error) {
135 tasknotesLogger.debug("Failed to decode project path:", {
136 category: "persistence",
137 operation: "decode-project-path",
138 details: { value: linkPath },
139 error: error,
140 });
141 }
142 return stripMarkdownExtension(linkPath);
143 }
144
145 return stripMarkdownExtension(trimmed);
146}
147
148function sanitizeProjectFilePath(path: string): string {
149 const normalizedPath = stripMarkdownExtension(path.trim()).replace(/\\/g, "/");

Callers 1

getProjectFilePathFunction · 0.85

Calls 2

stripMarkdownExtensionFunction · 0.85
debugMethod · 0.80

Tested by

no test coverage detected