Skip to content

Commit

Permalink
encode api url components
Browse files Browse the repository at this point in the history
  • Loading branch information
rvlzzr committed Aug 18, 2024
1 parent 516eb82 commit 36a3516
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/start/src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function containsHTTP(route: Route) {
const router = createRouter({
routes: (fileRoutes as unknown as Route[]).reduce((memo, route) => {
if (!containsHTTP(route)) return memo;
let path = route.path.replace(/\/\([^)/]+\)/g, "").replace(/\([^)/]+\)/g, "").replace(/\*([^/]*)/g, (_, m) => `**:${m}`);
let path = route.path.replace(/\/\([^)/]+\)/g, "").replace(/\([^)/]+\)/g, "").replace(/\*([^/]*)/g, (_, m) => `**:${m}`).split('/').map(s => (s.startsWith(':') || s.startsWith('*')) ? s : encodeURIComponent(s)).join('/');
if (/:[^/]*\?/g.test(path)) {
throw new Error(`Optional parameters are not supported in API routes: ${path}`);
}
Expand Down

0 comments on commit 36a3516

Please sign in to comment.