Update the CSS optimizer to end a URL path at a hash as well as a question mark

Fixes #17243

(cherry picked from commit cbe848ad3948f4a14ce8f0a1391d511370f6e07f)