`${BASE}/route` -- the JS/TS twin of #1249's `base + "/route"`. A template * that opens with one substitution and continues with a literal path is a * configurable base URL (`${process.env.BACKEND_URL}/wallet`), so the route is * the literal path after it. Anything else (`${a}${b}`, `${BASE}/`, a template * that opens with text) comes back unchanged: no path is fabricated (#2291). */
| 2855 | * the literal path after it. Anything else (`${a}${b}`, `${BASE}/`, a template |
| 2856 | * that opens with text) comes back unchanged: no path is fabricated (#2291). */ |
| 2857 | static const char *template_path_after_base(TSNode tpl, const char *flat) { |
| 2858 | if (ts_node_named_child_count(tpl) < PAIR_LEN || |
| 2859 | strcmp(ts_node_type(ts_node_named_child(tpl, 0)), "template_substitution") != 0) { |
| 2860 | return flat; |
| 2861 | } |
| 2862 | const char *path = flat + PAIR_LEN; /* past the base's "{}" placeholder */ |
| 2863 | /* `${base}/${tail}` has no literal path to recover: "/{}" is not a route. */ |
| 2864 | return (path[0] == '/' && cbm_url_has_literal_path(path)) ? path : flat; |
| 2865 | } |
| 2866 | |
| 2867 | static const char *extract_positional_url(CBMExtractCtx *ctx, TSNode arg, const char *ak, |
| 2868 | url_context_t *uc) { |
no test coverage detected