Refactor and fix parse_prefix on Windows
#78833
+141
−84
Merged