Refined regex matching for trailing slashes in urls