code: function makeRelPath(sourceUrl, targetUrl) {
    var source = sourceUrl.pathname;
    var target = targetUrl.pathname;
    var s = source.split('/');
    var t = target.split('/');
    while (s.length && s[0] === t[0]){
      s.shift();
      t.shift();
    }
    for (var i = 0, l = s.length - 1; i < l; i++) {
      t.unshift('..');
    }
    // empty '#' is discarded but we need to preserve it.
    var hash = (targetUrl.href.slice(-1) === URL_HASH) ? URL_HASH : targetUrl.hash;
    return t.join('/') + targetUrl.search + hash;
  }
docs: make a relative path from source to target