How to use the @reach/router/lib/utils.match function in @reach/router

To help you get started, we’ve selected a few @reach/router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jacobdcastro / personal-site / .cache / production-app.js View on Github external
)}
        
      )
    }
  }

  const { page, location: browserLoc } = window
  if (
    // Make sure the window.page object is defined
    page &&
    // The canonical path doesn't match the actual path (i.e. the address bar)
    __PATH_PREFIX__ + page.path !== browserLoc.pathname &&
    // ...and if matchPage is specified, it also doesn't match the actual path
    (!page.matchPath ||
      !match(__PATH_PREFIX__ + page.matchPath, browserLoc.pathname)) &&
    // Ignore 404 pages, since we want to keep the same URL
    page.path !== `/404.html` &&
    !page.path.match(/^\/404\/?$/) &&
    // Also ignore the offline shell (since when using the offline plugin, all
    // pages have this canonical path)
    !page.path.match(/^\/offline-plugin-app-shell-fallback\/?$/)
  ) {
    navigate(
      __PATH_PREFIX__ + page.path + browserLoc.search + browserLoc.hash,
      { replace: true }
    )
  }

  loader
    .getResourcesForPathname(browserLoc.pathname)
    .then(resources => {
github gatsbyjs / gatsby / packages / gatsby / cache-dir / find-page.js View on Github external
pages.some(page => {
    let pathToMatch = page.matchPath ? page.matchPath : page.path
    if (matchPath(pathToMatch, trimmedPathname)) {
      foundPage = page
      pageCache[trimmedPathname] = page
      return true
    }

    // Finally, try and match request with default document.
    if (matchPath(`${page.path}index.html`, trimmedPathname)) {
      foundPage = page
      pageCache[trimmedPathname] = page
      return true
    }

    return false
  })
github gatsbyjs / gatsby / packages / gatsby / cache-dir / find-page.js View on Github external
pages.some(page => {
    let pathToMatch = page.matchPath ? page.matchPath : page.path
    if (matchPath(pathToMatch, trimmedPathname)) {
      foundPage = page
      pageCache[trimmedPathname] = page
      return true
    }

    // Finally, try and match request with default document.
    if (matchPath(`${page.path}index.html`, trimmedPathname)) {
      foundPage = page
      pageCache[trimmedPathname] = page
      return true
    }

    return false
  })
github gatsbyjs / gatsby / packages / gatsby / cache-dir / find-path.js View on Github external
export const findMatchPath = rawPathname => {
  const trimmedPathname = cleanPath(rawPathname)

  for (const { matchPath, path } of matchPaths) {
    if (match(matchPath, trimmedPathname)) {
      return normalizePagePath(path)
    }
  }

  return null
}