Perf: Use charCodeAt in removeTrailingSlash (#91384)
Removes the regex usage for a simpler string replacement version as it
only reads from the end. Uses charCodeAt to avoid creating another
string.
---------
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>