Path resolver

Add a reply

Posted by arpad 675 days ago:
Here's an idea for a pretty simple challenge:

Given the absolute path to the current directory and another path, resolve the second path to its absolute form.
E.g.:


cwd: /foo

/foo/bar/baz.php => /foo/bar/baz.php
bar/baz.php => /foo/bar/baz.php
/foo/bar/../../baz.php => /baz.php
/foo/bar/../.././baz.php => /baz.php
/foo/bar/../.././/baz.php => /baz.php
/foo/bar/../../../baz.php => invalid


NB: The input paths shouldn't point to real files, otherwise (in PHP at least) people could just use realpath().

Add a reply