make sure endpoint names begin with a /

This commit is contained in:
Greg Johnston 2024-01-06 19:34:31 -05:00
parent db1497b9c2
commit f6b95e40f4

View file

@ -370,6 +370,13 @@ pub fn server_macro_impl(
};
// generate path
let fn_path_starts_with_slash = fn_path.to_string().starts_with("\"/");
let fn_path = if fn_path_starts_with_slash || fn_path.to_string() == "\"\""
{
quote! { #fn_path }
} else {
quote! { concat!("/", #fn_path) }
};
let path = quote! {
if #fn_path.is_empty() {
#server_fn_path::const_format::concatcp!(
@ -415,7 +422,6 @@ pub fn server_macro_impl(
#from_impl
impl #server_fn_path::ServerFn for #struct_name {
// TODO prefix
const PATH: &'static str = #path;
type Client = #client;