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", () => {
5858 } ) ;
5959 } ) . toThrow ( ) ;
6060
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+
6174 expect ( http . getRoutes ( ) ) . toEqual ( [
6275 [ "/path1" , "GET" , action1 ] ,
6376 [ "/path1" , "POST" , action2 ] ,
Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ export class HttpRouter {
177177 if ( ! spec . path . startsWith ( "/" ) ) {
178178 throw new Error ( `path '${ spec . path } ' does not start with a /` ) ;
179179 }
180+ if ( spec . path . startsWith ( "/.files/" ) || spec . path === "/.files" ) {
181+ throw new Error ( `path '${ spec . path } ' is reserved` ) ;
182+ }
180183 const methods : Map < RoutableMethod , PublicHttpAction > =
181184 this . exactRoutes . has ( spec . path )
182185 ? this . exactRoutes . get ( spec . path ) !
@@ -197,6 +200,9 @@ export class HttpRouter {
197200 if ( ! spec . pathPrefix . endsWith ( "/" ) ) {
198201 throw new Error ( `pathPrefix ${ spec . pathPrefix } must end with a /` ) ;
199202 }
203+ if ( spec . pathPrefix . startsWith ( "/.files/" ) ) {
204+ throw new Error ( `pathPrefix '${ spec . pathPrefix } ' is reserved` ) ;
205+ }
200206 const prefixes =
201207 this . prefixRoutes . get ( method ) || new Map < string , PublicHttpAction > ( ) ;
202208 if ( prefixes . has ( spec . pathPrefix ) ) {
You can’t perform that action at this time.
0 commit comments