A SvelteKit adapter that creates a Vercel app
—
Helper functions used internally by the adapter for route processing and pattern conversion. These functions are part of the adapter's internal implementation and are not exposed in the public API.
Generates pathname strings from SvelteKit route definitions for ISR (Incremental Static Regeneration) configuration.
/**
* Generates pathname from route segments for ISR configuration
* Converts dynamic route segments into numbered placeholders ($1, $2, etc.)
* @param route - SvelteKit route definition with segment information
* @returns Pathname string with parameter placeholders
*/
function get_pathname(route: RouteDefinition<any>): string;
// Supporting types from @sveltejs/kit
interface RouteDefinition<Config = any> {
id: string;
pattern: RegExp;
segments: Array<{
content: string;
dynamic: boolean;
rest: boolean;
}>;
methods: string[];
prerender?: boolean | 'auto';
config?: Config;
}Internal Usage Examples:
// Example of internal usage within the adapter
// These are not available for external import
// For route: /blog/[slug]
const route = {
segments: [
{ content: 'blog', dynamic: false, rest: false },
{ content: '[slug]', dynamic: true, rest: false }
]
};
const pathname = get_pathname(route);
// Result: "blog/$1"
// For route: /api/[...rest]
const restRoute = {
segments: [
{ content: 'api', dynamic: false, rest: false },
{ content: '[...rest]', dynamic: true, rest: true }
]
};
const restPathname = get_pathname(restRoute);
// Result: "api$1"
// For route with optional parameters: /shop/[[category]]/[id]
const optionalRoute = {
segments: [
{ content: 'shop', dynamic: false, rest: false },
{ content: '[[category]]', dynamic: true, rest: false },
{ content: '[id]', dynamic: true, rest: false }
]
};
const optionalPathname = get_pathname(optionalRoute);
// Result: "shop/$1/$2"Converts SvelteKit route regex patterns to Vercel routing source format for deployment configuration.
/**
* Adjusts stringified route regex for Vercel's routing system
* Converts SvelteKit route patterns to Vercel-compatible source patterns
* @param pattern - Stringified route regex from SvelteKit
* @returns Source pattern compatible with Vercel routing
*/
function pattern_to_src(pattern: string): string;Internal Usage Examples:
// Example of internal usage within the adapter
// These are not available for external import
// Root route conversion
const rootPattern = "/^/$/";
const rootSrc = pattern_to_src(rootPattern);
// Result: "^/?"
// Parameter route conversion
const paramPattern = "/^/foo/([^/]+?)/?$/";
const paramSrc = pattern_to_src(paramPattern);
// Result: "^/foo/([^/]+?)/?$"
// Optional parameter conversion
const optionalPattern = "/^/foo(/[^/]+)?/?$/";
const optionalSrc = pattern_to_src(optionalPattern);
// Result: "^/foo(/[^/]+)?/?$"
// Rest parameter conversion
const restPattern = "/^/foo(/[^]*)?/?$/";
const restSrc = pattern_to_src(restPattern);
// Result: "^/foo(/[^]*)?/?$"These utilities handle special cases in route processing:
The get_pathname function processes different types of dynamic segments:
[param]: Converted to $1, $2, etc.[[param]]: Converted to $1, $2, etc.[...rest]: Converted to $1, $2, etc.prefix-[param]-suffix: Converted to prefix-$1-suffixWhen a segment contains only a single optional or rest parameter, no leading slash is prepended to avoid incorrect trailing slash redirects in ISR scenarios.
// Single rest parameter segment
{ content: '[...rest]', dynamic: true, rest: true }
// Results in: "$1" (no leading slash)
// Rest parameter in mixed content
{ content: 'api-[...rest]', dynamic: true, rest: true }
// Results in: "/api-$1" (with leading slash)The pattern_to_src function optimizes patterns for Vercel's routing:
^/ becomes ^/?)// Non-capturing group optimization
// Input: "(?:/([^/]+))"
// Output: "(/$1)"
// This prevents empty rest parameters from creating unwanted trailing slashesInstall with Tessl CLI
npx tessl i tessl/npm-sveltejs--adapter-vercel