Skip to content

composePath() function

Home > @rimitive/router > composePath

Compose a parent path with a child path

Signature:

composePath: (parentPath: string, childPath: string) => string

Parameter

Type

Description

parentPath

string

Parent route path (e.g., ’/’, ‘/products’)

childPath

string

Child route path (e.g., ‘about’, ':id', ’*’)

Returns:

string

Combined path (e.g., ‘/about’, ‘/products/:id’, ’*‘)

import { composePath } from '@rimitive/router';
composePath('/', 'about'); // '/about'
composePath('/products', ':id'); // '/products/:id'
composePath('/api', 'users'); // '/api/users'
composePath('/any', '*'); // '*' (wildcard stays as wildcard)