path linkify: skip trailing-slash (directory) matches
This commit is contained in:
parent
2ad5a94897
commit
e772182724
1 changed files with 7 additions and 1 deletions
|
|
@ -48,7 +48,13 @@
|
||||||
// perspective (we'd need to know which agent the message is about
|
// perspective (we'd need to know which agent the message is about
|
||||||
// to translate it). Prefer `/agents/<name>/state/...` in agent
|
// to translate it). Prefer `/agents/<name>/state/...` in agent
|
||||||
// outputs and the link will resolve.
|
// outputs and the link will resolve.
|
||||||
const PATH_RE = /(\/var\/lib\/hyperhive\/agents\/[\w.-]+\/state\/[\w./-]+|\/var\/lib\/hyperhive\/shared\/[\w./-]+|\/agents\/[\w.-]+\/state\/[\w./-]+|\/shared\/[\w./-]+)/g;
|
// Each branch insists the tail is at least one segment AND the
|
||||||
|
// last character is `[\w.-]` (not `/`), so trailing-slash paths
|
||||||
|
// — i.e. plain directories — don't linkify. The /api/state-file
|
||||||
|
// endpoint also refuses non-files; this is the front-end peer so
|
||||||
|
// the operator doesn't see a dead link they'll just get an error
|
||||||
|
// from on click.
|
||||||
|
const PATH_RE = /(\/var\/lib\/hyperhive\/agents\/[\w.-]+\/state\/(?:[\w.-]+\/)*[\w.-]+|\/var\/lib\/hyperhive\/shared\/(?:[\w.-]+\/)*[\w.-]+|\/agents\/[\w.-]+\/state\/(?:[\w.-]+\/)*[\w.-]+|\/shared\/(?:[\w.-]+\/)*[\w.-]+)/g;
|
||||||
async function fetchStateFile(path) {
|
async function fetchStateFile(path) {
|
||||||
const resp = await fetch('/api/state-file?path=' + encodeURIComponent(path));
|
const resp = await fetch('/api/state-file?path=' + encodeURIComponent(path));
|
||||||
const text = await resp.text();
|
const text = await resp.text();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue