How to use the inferno-router.matchPath function in inferno-router

To help you get started, we’ve selected a few inferno-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 infernojs / inferno / packages / inferno-router / __tests__ / matchPath.spec.js View on Github external
it('creates a cache entry for each exact/strict pair', () => {
      // true/false and false/true will collide when adding booleans
      const trueFalse = matchPath('/one/two', {
        path: '/one/two/',
        exact: true,
        strict: false
      });
      const falseTrue = matchPath('/one/two', {
        path: '/one/two/',
        exact: false,
        strict: true
      });
      expect(!!trueFalse).toBe(true);
      expect(!!falseTrue).toBe(false);
    });
  });
github infernojs / inferno / packages / inferno-router / __tests__ / matchPath.spec.js View on Github external
it('creates a cache entry for each exact/strict pair', () => {
      // true/false and false/true will collide when adding booleans
      const trueFalse = matchPath('/one/two', {
        path: '/one/two/',
        exact: true,
        strict: false
      });
      const falseTrue = matchPath('/one/two', {
        path: '/one/two/',
        exact: false,
        strict: true
      });
      expect(!!trueFalse).toBe(true);
      expect(!!falseTrue).toBe(false);
    });
  });
github bs32g1038 / node-blog / blog / src / router-util / matchRoutes.js View on Github external
routes.some(route => {
    const match = route.path
      ? matchPath(pathname, route)
      : branch.length
        ? branch[branch.length - 1].match // use parent match
        : computeMatch(pathname); // use default "root" match

    if (match) {
      branch.push({ route, match });

      if (route.routes) {
        matchRoutes(route.routes, pathname, branch);
      }
    }

    return match;
  });
github infernojs / inferno / packages / inferno-router / __tests__ / matchPath.spec.js View on Github external
it('returns correct url at "/somewhere/else"', () => {
      const path = '/';
      const pathname = '/somewhere/else';
      const match = matchPath(pathname, path);
      expect(match.url).toBe('/');
    });
  });
github infernojs / inferno / packages / inferno-router / __tests__ / matchPath.spec.js View on Github external
it('returns non-sensitive url', () => {
      const options = {
        path: '/SomeWhere'
      };
      const pathname = '/somewhere';
      const match = matchPath(pathname, options);
      expect(match.url).toBe('/somewhere');
    });
github infernojs / inferno / packages / inferno-router / __tests__ / matchPath.spec.js View on Github external
it('returns correct url at "/"', () => {
      const path = '/';
      const pathname = '/';
      const match = matchPath(pathname, path);
      expect(match.url).toBe('/');
    });
github infernojs / inferno / packages / inferno-router / __tests__ / matchPath.spec.js View on Github external
it('returns correct url at "/somewhere/else"', () => {
      const path = '/somewhere';
      const pathname = '/somewhere/else';
      const match = matchPath(pathname, path);
      expect(match.url).toBe('/somewhere');
    });
  });
github infernojs / inferno / packages / inferno-router / __tests__ / matchPath.spec.js View on Github external
it('matches the root URL', () => {
      const match = matchPath('/test-location/7', {});
      expect(match.path).toBe('/');
      expect(match.url).toBe('/');
      expect(match.isExact).toBe(false);
      expect(match.params).toEqual({});
    });
  });
github infernojs / inferno / packages / inferno-router / __tests__ / matchPath.spec.js View on Github external
it('returns sensitive url', () => {
      const options = {
        path: '/SomeWhere',
        sensitive: true
      };
      const pathname = '/somewhere';
      const match = matchPath(pathname, options);
      expect(match).toBe(null);
    });
  });
github slupjs / slup / packages / Site / src / server.ts View on Github external
app.get('*', (req, res) => {
  /** Generate props for the mathing components in the router */
  const props = matchPath(routes, req.url)
  const App =  createElement(StaticRouter, props)
  const MatchURL = URLs.filter(item => item.url == req.url)[0]
  
  /** Render to string the generated JSX tree */
  const JSX = renderToStaticMarkup(App)

  /** Extract html, css string, plus an ids array for hydratation */
  const { css, html, ids } = SSR.extract(JSX)
  const IDs = JSON.stringify(ids)
  
  /** Render the page to the user based on the template */
  res.send(
    TEMPLATE
      .replace(/\r?\n|\r/g, '')
      .replace('{{TITLE}}', MatchURL ? MatchURL.title : 'Page Not Found')
      .replace('{{CSS}}', css)

inferno-router

Provides routing functionality for Inferno

MIT
Latest version published 5 months ago

Package Health Score

79 / 100
Full package analysis