pages: Refactored, exctracted duplicate code to URL module

Bug: 47657
Change-Id: Iafe6906c8b4c7ebf9ad8c65961797d65d996e87b