allow slashes in state keys

This commit is contained in:
Cadence Ember
2023-09-07 11:53:10 +12:00
parent 33dd73f809
commit 0caaa0940b
3 changed files with 25 additions and 7 deletions

View File

@@ -121,7 +121,8 @@ async function sendState(roomID, type, stateKey, content, mxid) {
assert.ok(type)
assert.ok(typeof stateKey === "string")
/** @type {Ty.R.EventSent} */
const root = await mreq.mreq("PUT", path(`/client/v3/rooms/${roomID}/state/${type}/${stateKey}`, mxid), content)
// encodeURIComponent is necessary because state key can contain some special characters like / but you must encode them so they fit in a single component of the URI
const root = await mreq.mreq("PUT", path(`/client/v3/rooms/${roomID}/state/${type}/${encodeURIComponent(stateKey)}`, mxid), content)
return root.event_id
}