Probably not the best solution, but as an interim fix for this specific case, I added the following before line 128:
$value = preg_replace('/\|/', '%7C', $value);
I’m sure there is a better solution, but this will work for this specific case I have until a better fix is implemented.
I couldn’t figure it out with my limited experience, but it seems the better logic might be to split incoming urls and run urlencode($querystring) on the query string portion, and eliminate whatever the cause of the problem is.
Or, since the URL was being saved properly in the mysql table, perhaps the better solution might be in the count_and_redirect function to fix whatever is causing it to see | as not being a part of the outputted url?