Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@umijs/route-utils

Package Overview
Dependencies
Maintainers
11
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@umijs/route-utils

Quickly process the routing of umi

  • 4.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
11
Created

What is @umijs/route-utils?

@umijs/route-utils is a utility library for managing and manipulating routes in UmiJS applications. It provides a set of functions to handle route configurations, flatten nested routes, and match routes based on paths.

What are @umijs/route-utils's main functionalities?

Flatten Nested Routes

This feature allows you to flatten nested route configurations into a single-level array. This can be useful for simplifying route management and ensuring all routes are easily accessible.

const { flattenRoutes } = require('@umijs/route-utils');

const nestedRoutes = [
  {
    path: '/',
    routes: [
      { path: '/home', component: 'Home' },
      { path: '/about', component: 'About' }
    ]
  }
];

const flatRoutes = flattenRoutes(nestedRoutes);
console.log(flatRoutes);

Match Routes

This feature allows you to match a given path against a set of routes and retrieve the matched route(s). This is useful for route validation and dynamic route handling.

const { matchRoutes } = require('@umijs/route-utils');

const routes = [
  { path: '/home', component: 'Home' },
  { path: '/about', component: 'About' }
];

const matchedRoutes = matchRoutes(routes, '/home');
console.log(matchedRoutes);

Generate Route Paths

This feature allows you to generate a path string from a path template and parameters. It is useful for creating dynamic URLs based on route parameters.

const { generatePath } = require('@umijs/route-utils');

const pathTemplate = '/user/:id';
const path = generatePath(pathTemplate, { id: 123 });
console.log(path);

Other packages similar to @umijs/route-utils

FAQs

Package last updated on 05 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc