code: function(path, base)
          {
              base = base ? base + "/" : "/";
              if(
                  !hasProtocol(base, base.substr(0, 2))
              ) {
                  base = location.origin + base;
              }
              var url = new URL(path, base);
              path = url.origin + url.pathname;
              path = path.replace(location.origin, "");
              // path = new URL(path, base).href.replace(location.origin, "");
              // if it has a trailing slash i.e. a directory, remove the trailing slash
              var len = path.length - 1;
              return path[len] === "/" ? path.substr(0, len) : path;
          }
docs: base should always be without a trailing /