Given two absolute paths, e.g.
/var/data/stuff/xyz.html
/var/data
How to create a relative path that uses the second path as its base? In the example above, the result would be: stuff/xyz.html
Another example:
/relative/sub/foo/sub/file
/relative/path
../../../path
This is similar to this question but I'm looking for the optimal JavaScript solution instead of Java.