code: function parentHref(href, noTrailingSlash) {
    href = str(href).replace(/\/\/+/g, '/');
    var pmatch = href.match(/(.*\/)[^/]+(\/$|$)/);
    return pmatch && (noTrailingSlash ? (pmatch[1].slice(0,-1) || '/') : pmatch[1]);
  }
docs: return parent href given href replaces multiple / with single / but does not normalize ../ returns null for / or href without / if noTrailingSlash, return parent path without the slash see tests for edge cases