medialize/URI.js — pull request #103 by djcsdy (2013-08-07 23:30:06+00:00)
Title: Inconsistent path relativization

Oops, we broke something in `relativeTo()` :(.

Since the last release, `relativeTo()` behaves inconsistently for relative URIs that contain an absolute path but no scheme or authority.

This works as expected:

```js
URI("/a/b/c").relativeTo("/a/"); // -> "b/c"
```

This should be equivalent, but since the last release it produces a different result:

```js
URI("http://example.org/a/b/c").scheme("").authority("").relativeTo("/a/"); // -> "/a/b/c"
```

Which is curious because the two URIs to be relativized are equivalent:

```js
URI("/a/b/c").toString(); // -> "/a/b/c"
URI("http://example.org/a/b/c").scheme("").authority("").toString(); // -> "/a/b/c"
```

Of course, path relativization and URI relativization are fundamentally different things. A URI that contains only a path component is already relative, so it's not entirely clear what the expected behaviour of `relativeTo()` should be. This is the sort of thing I was talking about when I said that the definition of `relativeTo()` needs to be tightened up :).

Of course, using `relativeTo()` to relativize an absolute path used to work, so it should continue to work.

It's probably me that broke this, sorry about that. I need this functionality for a commercial project I'm working on, so I will certainly get around to fixing it sooner or later if you don't beat me to it. Possibly this week, but I'm not sure yet :).