react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

fix: correct path handling for file name extraction in `rss.js`

Open lumirlumir opened this issue 1 year ago • 2 comments
trafficstars

fix: correct path handling for file name extraction in rss.js

Hello😊 Thank you for your attention to this matter :)

1. Description

This PR addresses an issue with path handling in rss.js. This makes it impossible for Windows users to run dev server through yarn dev.

The problem was identified when the generateRssFeed method failed to exclude the index.md file correctly, causing errors due to missing metadata fields required for RSS feeds.

image image

2. Solution

The solution is to use the path.basename method, which correctly extracts the file name from a path regardless of the operating system's path separator(/ or \). Here are the key changes made:

  • Previous method
const id = filePath.split('/').slice(-1).join('');
  • Improved method
const id = path.basename(filePath);

This ensures that the file name is accurately extracted, and the index.md file is correctly excluded from the RSS feed generation process.

3. Conclusion

This PR fixes the path handling issues, ensuring compatibility across different operating systems(Windows or Linux/Mac) by using the appropriate methods for file name extraction and path manipulation.

lumirlumir avatar Jul 01 '24 04:07 lumirlumir

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
19-react-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 5:00am
react-dev ✅ Ready (Inspect) Visit Preview Jul 1, 2024 5:00am

vercel[bot] avatar Jul 01 '24 04:07 vercel[bot]

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

github-actions[bot] avatar Jul 01 '24 05:07 github-actions[bot]

Closing this as stale; it looks like it won’t be fixed.

lumirlumir avatar Jul 05 '25 10:07 lumirlumir