% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/route.R
\name{as_path_to_pattern}
\alias{as_path_to_pattern}
\title{Path to pattern}
\usage{
as_path_to_pattern(path)
}
\arguments{
\item{path}{A function that accepts a character vector of length 1
and returns another character vector of length 1.}
}
\value{
Object of class "pathToPattern".
}
\description{
Identify a function as a path to pattern function;
a function that accepts a path and returns a matching pattern.
}
\examples{
fn <- function(path) {
  pattern <- gsub(":([^/]+)", "(\\\\\\\\w+)", path)
  paste0("^", pattern, "$")
}

path_to_pattern <- as_path_to_pattern(fn)

path <- "/dashboard/profile/:user_id"
pattern <- path_to_pattern(path) # "^/dashboard/profile/(\\w+)$"

}
