(project: string)
| 111 | } |
| 112 | |
| 113 | function 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 | |
| 148 | function sanitizeProjectFilePath(path: string): string { |
| 149 | const normalizedPath = stripMarkdownExtension(path.trim()).replace(/\\/g, "/"); |
no test coverage detected