fix .md urls not rendering partials#2776
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds an exported async function Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/server/markdown.ts`:
- Line 24: The catch clause currently declares an unused exception variable `e`
(catch (e) { ... }); update the catch to either remove the binding (use `catch {
... }`) or rename it to `_e` to signal intentional discard (e.g., `catch (_e) {
... }`) so ESLint no longer flags it; change the catch header in the same block
where `catch (e)` appears in markdown.ts and keep the existing catch body
unchanged.
- Line 31: The current use of result.replace(fullMatch, partialContent) only
replaces the first occurrence of the partial marker; change it to replace all
occurrences by using result = result.replaceAll(fullMatch, partialContent) or,
if you need broader compatibility/partial contains regex chars, build a global
regex with an escaped fullMatch (e.g. new RegExp(escapeRegExp(fullMatch), 'g'))
and use result = result.replace(regex, partialContent); update the line that
references fullMatch and partialContent in markdown.ts accordingly.
- Around line 19-23: The code reads partials using partialsCache, partialFile
and partialsDir without validating the resolved path, allowing path traversal;
fix by resolving the candidate path (e.g., const resolved =
resolve(join(partialsDir, partialFile))) and ensure the resolved path starts
with the resolved partialsDir (e.g., const base = resolve(partialsDir); if
(!resolved.startsWith(base + path.sep) && resolved !== base) throw or skip)
before calling readFile and caching; mirror the same resolve()/startsWith()
pattern already used in getMarkdownContent to locate and validate the partial
safely.
Summary by CodeRabbit