Open josephjclark opened 1 month ago
This has bitten TD a couple of times in the last couple of days - we really shouldn't be so brittle
Using undici's baseUrl is a pattern we should use more - undici will deal with at least the base slash. That means adaptors need to use baseUrl rather than assembling their own url. The template needs to do this too
This issue affects many adaptors (especially some of our new ones!)
When building URLs, we often use patterns like
www.blah.com/${appId}/${path}
, wherepath
is a user defined value.But should path start with a
/
? Or end with one?In practice it shouldn't matter, and I think usually it doesn't matter. But we should take care to build well-formed URLs which are robust to leading and trailing slashes from users.
I thought we could use the URL global object for this but on checking the API I'm not so sure. We might be better off using
node:path.resolve(a,b,c)
to build the pathSee
commcare
for an example of this.