Skip to content

Commit

Permalink
chore: Improve news path parsing when listing Arch news
Browse files Browse the repository at this point in the history
The command historically used for news path parsing was chaining multiple 'sed' calls in an unoptimized way. Everything is now merged into a single 'sed' call.
  • Loading branch information
Antiz96 committed Dec 20, 2024
1 parent 336bb90 commit a7e58e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/list_news.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ else
if [ "${num}" -le "${news_num}" ] 2> /dev/null && [ "${num}" -gt "0" ]; then
printed_news="true"
news_selected=$(sed -n "${num}"p <<< "${news_titles}")
news_path=$(echo "${news_selected}" | sed s/\ -//g | sed s/\ /-/g | sed s/[.]//g | sed s/=//g | sed s/\>//g | sed s/\<//g | sed s/\`//g | sed s/://g | sed s/+//g | sed s/[[]//g | sed s/]//g | sed s/,//g | sed s/\(//g | sed s/\)//g | sed s/[/]//g | sed s/@//g | sed s/\'//g | sed s/--/-/g | awk '{print tolower($0)}')
news_path=$(echo "${news_selected}" | sed -E 's/[.=><`:+@,()\[\]'"'"']//g; s/ /-/g; s/--/-/g' | tr '[:upper:]' '[:lower:]')
news_url="https://www.archlinux.org/news/${news_path}"
news_content=$(curl -m 30 -Lfs "${news_url}" || echo "error")

Expand Down

0 comments on commit a7e58e5

Please sign in to comment.