Luligu/matterbridge

Frontend appends trailing slash to plugin configUrl, corrupting query strings (since 3.9.2)

開放

#579 建立於 2026年7月11日

 (2 則留言) (0 個反應) (1 位負責人)TypeScript (53 個分叉)auto 404
help wanted

倉庫指標

星標
 (938 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Since 3.9.2, the frontend's handleConfigUrl normalizes a device's configUrl before loading it in the plugin-frontend iframe (introduced with the Ingress base-path support):

const t = ${basePath}${configUrl.replace(/^\.?\//, '')};
const n = t.endsWith('/') ? t : ${t}/; // ← appends '/' blindly

The trailing-slash normalization ignores query strings. A plugin configUrl like:

/plugins/matterbridge-mqtt-devices/?device=temp1 becomes: /plugins/matterbridge-mqtt-devices/?device=temp1/

The slash lands inside the query value, so the plugin page receives device=temp1/, its GET /plugins/<name>/api/config?device=temp1%2F lookup fails, and onFetch returning undefined produces a 404 — the config page renders empty. This worked in 3.9.1, which passed configUrl to the iframe verbatim.

Steps to reproduce

Install a plugin whose device configUrl carries a query string, e.g. matterbridge-mqtt-devices (/plugins/matterbridge-mqtt-devices/?device=<id>). Open the device's config page from the Devices view on Matterbridge ≥3.9.2. The plugin frontend loads, but the query parameter arrives with a trailing / appended. Expected behavior The trailing slash should only be applied to the path portion, e.g.:

const url = new URL(t, window.location.origin);
if (!url.pathname.endsWith('/')) url.pathname += '/';

Reported downstream: hobbyquaker/matterbridge-mqtt-devices#2 (worked around plugin-side in 0.10.4 by stripping trailing slashes from the query value).

貢獻者指南