Skip to content

baseRoutePath

reference
1 min readUpdated

Kind: Function

Source: src/helper/route/index.ts

Part of: Helper

Get the basePath of the as-is route specified by routing.

baseRoutePath returns the base path for the route described by routing. Use it when route-aware code needs the declared path without duplicating route-path handling.

Signature

ts
function baseRoutePath(c: Context, index: number): string

Parameters

NameType
cContext
indexnumber

Returns: string

Diagram

mermaid
graph LR
  A[Routing value] --> B[baseRoutePath]
  B --> C[Base route path]

Usage

ts
import { baseRoutePath } from '@/helper/route';

const routing = '/articles/[slug]';

const path = baseRoutePath(routing);

// Use the base route path in route-aware logic.
console.log(path);

AI Coding Instructions

  • Pass the routing value from the route configuration rather than rebuilding its path in calling code.
  • Keep route parsing and base-path extraction inside baseRoutePath.
  • Preserve dynamic route segments when passing route definitions to this function.
  • Update callers if the routing value format changes.

Was this page helpful?

Download as PDF
baseRoutePath — Hono (narrator proof)