Skip to content

Commit f3d9470

Browse files
committed
Fix #17
1 parent edd1a08 commit f3d9470

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

R/Plumber.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

R/aaa.R

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)