updated code to return correct path in case of missing trailing slash for example: http://example.com:3000?search=test#hash