File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -282,7 +282,7 @@ Plumber <- R6Class(
282282 })
283283
284284 # Substitute the plumber style path arg for a routr style
285- path <- stri_replace_all_regex (path , " <(.+?)(:.+?)?> " , " :$1 " )
285+ path <- as_routr_path (path )
286286
287287 if (header ) {
288288 router <- self $ header_router
Original file line number Diff line number Diff line change @@ -13,10 +13,27 @@ as_openapi_path <- function(x) {
1313 )
1414}
1515
16- as_routr_path <- function (x ) {
17- stringi :: stri_replace_all_regex(
16+ as_routr_path <- function (x , call = caller_env() ) {
17+ path <- stringi :: stri_replace_all_regex(
1818 x ,
1919 " <(.+?)(:.+?)?>" ,
2020 " :$1"
2121 )
22+ params <- sub(" :" , " " , stringi :: stri_extract_all_regex(x , " :[^/]+" )[[1 ]])
23+
24+ protected_names <- c(
25+ " request" ,
26+ " response" ,
27+ " server" ,
28+ " client_id" ,
29+ " query" ,
30+ " body"
31+ )
32+ if (any(params %in% protected_names )) {
33+ cli :: cli_abort(c(
34+ " Path parameters must not take the name of any of the arguments that are passed to the handler" ,
35+ i = " Rename any parameters named {.or {.val {protected_names}}}"
36+ ))
37+ }
38+ path
2239}
You can’t perform that action at this time.
0 commit comments