mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 17:25:32 +00:00
12 lines
387 B
JavaScript
12 lines
387 B
JavaScript
htmx.defineExtension('path-params', {
|
|
onEvent: function(name, evt) {
|
|
if (name === 'htmx:configRequest') {
|
|
evt.detail.path = evt.detail.path.replace(/{([^}]+)}/g, function(_, param) {
|
|
var val = evt.detail.parameters[param]
|
|
delete evt.detail.parameters[param]
|
|
return val === undefined ? '{' + param + '}' : encodeURIComponent(val)
|
|
})
|
|
}
|
|
}
|
|
})
|