CodeQL flagged `/\/+$/` as polynomial-time on repeated slashes. Use `while (endsWith("/"))` loop instead.