UNPKG

437 BJavaScriptView Raw
1htmx.defineExtension('path-params', {
2 onEvent: function(name, evt) {
3 if (name === "htmx:configRequest") {
4 evt.detail.path = evt.detail.path.replace(/{([^}]+)}/g, function (_, param) {
5 var val = evt.detail.parameters[param];
6 delete evt.detail.parameters[param];
7 return val === undefined ? "{" + param + "}" : encodeURIComponent(val);
8 })
9 }
10 }
11});
\No newline at end of file