Skip to content

Commit

Permalink
fix: trim feed content before pattern matching
Browse files Browse the repository at this point in the history
Adds whitespace trimming before applying XML pattern matching to ensure consistent feed processing and prevent potential issues with leading/trailing spaces.
  • Loading branch information
ccbikai committed Dec 31, 2024
1 parent 3fed962 commit 1b3e290
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export async function getFeed(feedUrl, { headers = {} } = {}) {
style = `<?xml-stylesheet type="text/xsl" href="/atom.xsl" ?>`
}

return feedText.replace(/^(<\?xml .*\?>)?(.*)$/s, `$1${style}$2`)
return feedText.trim().replace(/^(<\?xml .*\?>)?(.*)$/s, `$1${style}$2`)
}

0 comments on commit 1b3e290

Please sign in to comment.