api-helper: Use 'sed' to remove tracking parameters

This commit is contained in:
Samantaz Fox 2023-02-15 23:41:12 +01:00
parent 5f20877542
commit a9b2a07a1c
No known key found for this signature in database
GPG key ID: F42821059186176E

View file

@ -483,8 +483,19 @@ fi
hdr_ua="User-Agent: ${user_agent}"
# Default to STDOUT if no output file was given
if [ -z "$output" ]; then output='-'; fi
# Run!
curl --compressed -o "$output" -H "$hdr_ct" -H "$hdr_ua" --data "$data" "$url"
result=$(
curl --compressed -H "$hdr_ct" -H "$hdr_ua" --data "$data" "$url" | \
sed -E '
/^\s+"(clickT|t)rackingParams.+,$/d
s/,?\n\s+"(clickT|t)rackingParams.+$//
'
)
# Default to STDOUT if no output file was given
if [ -z "$output" ]; then
echo "$result"
else
echo "$result" > "$output"
fi