Fix JS comment
Reverse page mapping object

Simplify the loop and allow finer control over path matching.