Public API for matching a URL pathname to a path.
function matchPath(pathname, options = {}) {
  if (typeof options === 'string') options = { path: options };

  const {
    path, exact = false, strict = false, sensitive = false
  } = options;

  const paths = [].concat(path);

  return paths.reduce((matched, p) => {
    if (matched) return matched;
    const { regexp, keys } = compilePath(p, {
      end: exact,
      strict,
      sensitive
    });
    const match = regexp.exec(pathname);

    if (!match) return null;

    const [url, ...values] = match;
    const isExact = pathname === url;

    if (exact && !isExact) return null;

    return {
      path: p, // the p used to match
      url: p === '/' && url === '' ? '/' : url, // the matched portion of the URL
      isExact, // whether or not we matched exactly
      params: keys.reduce((memo, key, index) => {
        memo[key.name] = values[index];
        return memo;
      }, {})
    };
  }, null);
}