Enhanced keyToPath() to URL-escape keys