Fix #20022: Correctly handle prefixes with url-unsafe characters in reverse()