@@ -746,20 +746,28 @@ static void handle_string_constants(CBMExtractCtx *ctx, TSNode node, const WalkS
746746 return ;
747747 }
748748
749- /* Value must be a string literal */
750- if (!is_string_node (ts_node_type (value_node ))) {
749+ /* Value must be a string literal (template literals flatten to "{}" form) */
750+ const char * value_kind = ts_node_type (value_node );
751+ const char * flat_value = NULL ;
752+ if (strcmp (value_kind , "template_string" ) == 0 ) {
753+ flat_value = cbm_template_string_text (ctx -> arena , value_node , ctx -> source );
754+ if (!flat_value ) {
755+ return ;
756+ }
757+ } else if (!is_string_node (value_kind )) {
751758 return ;
752759 }
753760
754761 char * name = cbm_node_text (ctx -> arena , name_node , ctx -> source );
755- char * value = cbm_node_text (ctx -> arena , value_node , ctx -> source );
762+ char * value =
763+ flat_value ? (char * )flat_value : cbm_node_text (ctx -> arena , value_node , ctx -> source );
756764 if (!name || !name [0 ] || !value || !value [0 ]) {
757765 return ;
758766 }
759767
760- /* Strip quotes from value */
768+ /* Strip quotes from value (template values are already unquoted) */
761769 int vlen = (int )strlen (value );
762- if (vlen >= CBM_QUOTE_PAIR && (value [0 ] == '"' || value [0 ] == '\'' )) {
770+ if (! flat_value && vlen >= CBM_QUOTE_PAIR && (value [0 ] == '"' || value [0 ] == '\'' )) {
763771 value = cbm_arena_strndup (ctx -> arena , value + SKIP_ONE , (size_t )(vlen - PAIR_LEN ));
764772 if (!value ) {
765773 return ;
@@ -789,6 +797,27 @@ static bool is_string_node(const char *kind) {
789797
790798static void handle_string_refs (CBMExtractCtx * ctx , TSNode node , const WalkState * state ) {
791799 const char * kind = ts_node_type (node );
800+ /* JS/TS template literals: flatten ${...} substitutions to "{}" so URL-ish
801+ * template strings become string_refs with the canonical placeholder shape
802+ * shared with server route paths (issue #1006). */
803+ if (strcmp (kind , "template_string" ) == 0 ) {
804+ const char * flat = cbm_template_string_text (ctx -> arena , node , ctx -> source );
805+ if (!flat ) {
806+ return ;
807+ }
808+ int kind_val = cbm_classify_string (flat , (int )strlen (flat ));
809+ if (kind_val < 0 ) {
810+ return ;
811+ }
812+ CBMStringRef ref = {
813+ .value = flat ,
814+ .enclosing_func_qn =
815+ state -> enclosing_func_qn ? state -> enclosing_func_qn : ctx -> module_qn ,
816+ .kind = (CBMStringRefKind )kind_val ,
817+ };
818+ cbm_stringref_push (& ctx -> result -> string_refs , ctx -> arena , ref );
819+ return ;
820+ }
792821 if (!is_string_node (kind )) {
793822 return ;
794823 }
0 commit comments