Fix bugs in match_path_pattern