1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Shared routing glue for the `<browser>[/<tab>]` positional commands
//! (`eval`, `fetch`, `storage`, …).
//!
//! These commands all parse the same positional shape and then peel the
//! `/<tab>` suffix back off to recover the bare `<browser>` selector for
//! [`crate::cli::mcp::resolve_browser`]. Keeping that one operation here
//! avoids the three identical copies the routing handlers used to carry.
/// Strip a `/<tab>` suffix from a raw `<browser>[/<tab>]` positional.
///
/// `tab` is the tab name already parsed out of `raw` (via
/// [`crate::cli::env_resolver::parse_target`]). When `Some`, the matching
/// `/<name>` suffix is removed; if `raw` doesn't actually end in that
/// suffix the original is returned unchanged (defensive — the caller
/// derives `tab` from the same `raw`, so a mismatch shouldn't happen).