I kinda hate this, but not sure what else to do. It might be worth rewriting sanitizePath in the future to loop through the string once, but I think this is good enough for now.