File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
npm-packages/convex/src/server Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,19 @@ test("HttpRouter", () => {
58
58
} ) ;
59
59
} ) . toThrow ( ) ;
60
60
61
+ expect ( ( ) => {
62
+ http . route ( { pathPrefix : "/.files/" , method : "GET" , handler : action1 } ) ;
63
+ } ) . toThrow ( "pathPrefix '/.files/' is reserved" ) ;
64
+ expect ( ( ) => {
65
+ http . route ( { path : "/.files" , method : "GET" , handler : action1 } ) ;
66
+ } ) . toThrow ( "is reserved" ) ;
67
+ expect ( ( ) => {
68
+ http . route ( { path : "/.files/" , method : "GET" , handler : action1 } ) ;
69
+ } ) . toThrow ( "is reserved" ) ;
70
+ expect ( ( ) => {
71
+ http . route ( { path : "/.files/foo/bar" , method : "GET" , handler : action1 } ) ;
72
+ } ) . toThrow ( "is reserved" ) ;
73
+
61
74
expect ( http . getRoutes ( ) ) . toEqual ( [
62
75
[ "/path1" , "GET" , action1 ] ,
63
76
[ "/path1" , "POST" , action2 ] ,
Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ export class HttpRouter {
177
177
if ( ! spec . path . startsWith ( "/" ) ) {
178
178
throw new Error ( `path '${ spec . path } ' does not start with a /` ) ;
179
179
}
180
+ if ( spec . path . startsWith ( "/.files/" ) || spec . path === "/.files" ) {
181
+ throw new Error ( `path '${ spec . path } ' is reserved` ) ;
182
+ }
180
183
const methods : Map < RoutableMethod , PublicHttpAction > =
181
184
this . exactRoutes . has ( spec . path )
182
185
? this . exactRoutes . get ( spec . path ) !
@@ -197,6 +200,9 @@ export class HttpRouter {
197
200
if ( ! spec . pathPrefix . endsWith ( "/" ) ) {
198
201
throw new Error ( `pathPrefix ${ spec . pathPrefix } must end with a /` ) ;
199
202
}
203
+ if ( spec . pathPrefix . startsWith ( "/.files/" ) ) {
204
+ throw new Error ( `pathPrefix '${ spec . pathPrefix } ' is reserved` ) ;
205
+ }
200
206
const prefixes =
201
207
this . prefixRoutes . get ( method ) || new Map < string , PublicHttpAction > ( ) ;
202
208
if ( prefixes . has ( spec . pathPrefix ) ) {
You can’t perform that action at this time.
0 commit comments