Path manipulation functions for JavaScript