Closed DoCode closed 6 years ago
Hi @DoCode. For this You should use the +
operator instead of the /
one:
UriTemplate.For("http://localhost/resource1/{+resource2}{?q,pageindex,pagesize}")
.WithParameter("resource2", "path/to/my/resource")
.WithParameter("pagesize", 10)
.ExpandToString();
Thanks a lot! That's what I needed.
When the resource2
is null, can a slash included inside the operator, like {/+resource2}
I'm not sure if the RFC6570 allows that, but maybe you can do something like that to handle null values:
UriTemplate.For("http://localhost/resource1{+resource2}{?q,pageindex,pagesize}")
.WithParameter("resource2", variable?.EnsureRelativeUrl())
.WithParameter("pagesize", 10)
.ExpandToString();
where EnsureRelativeUrl
is a method that prefixes this string with a \
char if it does not start with it.
How can I disable the encoding for path segments with a forwarding slash inside?
Template:
the data:
should result in