Rocky_Mountain_Vending/.pnpm-store/v10/files/af/27da674a96c0295c05c31dd12e6f0fc7db99cd7b01f5b55e452224358d535ea8931946d97aa9b4a7f037690d56cffd32b7e4d2b3cf4042c027166bda1775d2
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

50 lines
No EOL
1.7 KiB
Text

import { ensureLeadingSlash } from '../../page-path/ensure-leading-slash';
import { isGroupSegment } from '../../segment';
/**
* Normalizes an app route so it represents the actual request path. Essentially
* performing the following transformations:
*
* - `/(dashboard)/user/[id]/page` to `/user/[id]`
* - `/(dashboard)/account/page` to `/account`
* - `/user/[id]/page` to `/user/[id]`
* - `/account/page` to `/account`
* - `/page` to `/`
* - `/(dashboard)/user/[id]/route` to `/user/[id]`
* - `/(dashboard)/account/route` to `/account`
* - `/user/[id]/route` to `/user/[id]`
* - `/account/route` to `/account`
* - `/route` to `/`
* - `/` to `/`
*
* @param route the app route to normalize
* @returns the normalized pathname
*/ export function normalizeAppPath(route) {
return ensureLeadingSlash(route.split('/').reduce((pathname, segment, index, segments)=>{
// Empty segments are ignored.
if (!segment) {
return pathname;
}
// Groups are ignored.
if (isGroupSegment(segment)) {
return pathname;
}
// Parallel segments are ignored.
if (segment[0] === '@') {
return pathname;
}
// The last segment (if it's a leaf) should be ignored.
if ((segment === 'page' || segment === 'route') && index === segments.length - 1) {
return pathname;
}
return `${pathname}/${segment}`;
}, ''));
}
/**
* Strips the `.rsc` extension if it's in the pathname.
* Since this function is used on full urls it checks `?` for searchParams handling.
*/ export function normalizeRscURL(url) {
return url.replace(/\.rsc($|\?)/, // $1 ensures `?` is preserved
'$1');
}
//# sourceMappingURL=app-paths.js.map