route into a file manager's address bar; it always starts with a slash /. Reduce it to its short canonical form.
How a path is read:
- . is the current folder and can simply be skipped;
- .. moves up to the parent folder; at the root there is nowhere to go, so .. does nothing there;
- several slashes in a row (//, ///) count as one;
- any other run of dots, such as ... or ...., is an ordinary folder name.
The canonical path starts with a single /, separates folders with exactly one slash, has no trailing slash (unless the whole path is the root /), and contains no . or .. steps. Return it as a string.route="/docs//drafts/./final/" → '/docs/drafts/final'
The double slash collapses, . means "stay here", and the trailing slash is dropped.
route="/music/rock/../jazz/.." → '/music'
We step back from rock into music, enter jazz, then step back up again, leaving /music.
route="/../../.../x" → '/.../x'
You cannot climb above the root, and ... is just an ordinary folder name.
route consists of English letters, digits, ., / and _route starts with /route="/docs//drafts/./final/"
'/docs/drafts/final'
Run checks the first 3 tests in your browser. Submit checks all 201 tests on the server, hidden ones included.