How to use the inferno-shared.toArray function in inferno-shared

To help you get started, we’ve selected a few inferno-shared 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 / src / match.ts View on Github external
function matchRoutes(
  _routes,
  currentURL = "/",
  parentPath = "/",
  redirect = false
) {
  const routes = isArray(_routes) ? flatten(_routes) : toArray(_routes);
  const [pathToMatch = "/", search = ""] = currentURL.split("?");
  const params = mapSearchParams(search);

  routes.sort(pathRankSort);

  for (let i = 0, len = routes.length; i < len; i++) {
    const route = routes[i];
    const props = route.props || emptyObject;
    const routePath = props.from || props.path || "/";
    const location =
      parentPath + toPartialURL(routePath, parentPath).replace(/\/\//g, "/");
    const isLast = isEmpty(props.children);
    const matchBase = matchPath(isLast, location, pathToMatch);

    if (matchBase) {
      let children = props.children;
github infernojs / inferno / packages / inferno-router / src / match.ts View on Github external
export default function match(routes, currentURL: any) {
  const location: string = getURLString(currentURL);
  return matchRoutes(toArray(routes), encodeURI(location), "/");
}