@@ -3230,6 +3230,57 @@ TEST(extract_ts_template_string_url_issue1006) {
32303230 PASS ();
32313231}
32323232
3233+ /* Issue #1249: a mux route built as `configVar + "/literal"` (Go's idiomatic
3234+ * configurable-base-path pattern) must index the literal suffix, both for a
3235+ * route registration and for an outbound URL built the same way. A real BFF
3236+ * with 47 such registrations produced only 9 Route nodes before this fix. */
3237+ TEST (extract_go_binary_concat_url_issue1249 ) {
3238+ CBMFileResult * r = extract ("package main\n"
3239+ "import \"net/http\"\n"
3240+ "func setup(mux *http.ServeMux, base string) {\n"
3241+ " mux.HandleFunc(base+\"/login\", loginHandler)\n"
3242+ "}\n"
3243+ "func report(host string, port string) {\n"
3244+ " http.Get(\"http://\" + host + \":\" + port + \"/log\")\n"
3245+ "}\n" ,
3246+ CBM_LANG_GO , "t" , "routes.go" );
3247+ ASSERT_NOT_NULL (r );
3248+ ASSERT_FALSE (r -> has_error );
3249+
3250+ const CBMCall * reg = find_call_by_callee (r , "mux.HandleFunc" );
3251+ ASSERT_NOT_NULL (reg );
3252+ ASSERT_NOT_NULL (reg -> first_string_arg );
3253+ ASSERT_STR_EQ (reg -> first_string_arg , "/login" );
3254+
3255+ const CBMCall * out = find_call_by_callee (r , "http.Get" );
3256+ ASSERT_NOT_NULL (out );
3257+ ASSERT_NOT_NULL (out -> first_string_arg );
3258+ ASSERT_STR_EQ (out -> first_string_arg , "/log" );
3259+
3260+ cbm_free_result (r );
3261+ PASS ();
3262+ }
3263+
3264+ /* Same issue: when the right side of the concatenation is not itself a
3265+ * literal (`base + suffixVar`), there is no literal route to recover. The
3266+ * fix must leave this unresolved rather than fabricate a path. */
3267+ TEST (extract_go_binary_concat_url_no_literal_suffix_issue1249 ) {
3268+ CBMFileResult * r = extract ("package main\n"
3269+ "func setup(mux *http.ServeMux, base string, suffix string) {\n"
3270+ " mux.HandleFunc(base+suffix, dynHandler)\n"
3271+ "}\n" ,
3272+ CBM_LANG_GO , "t" , "routes.go" );
3273+ ASSERT_NOT_NULL (r );
3274+ ASSERT_FALSE (r -> has_error );
3275+
3276+ const CBMCall * reg = find_call_by_callee (r , "mux.HandleFunc" );
3277+ ASSERT_NOT_NULL (reg );
3278+ ASSERT_NULL (reg -> first_string_arg );
3279+
3280+ cbm_free_result (r );
3281+ PASS ();
3282+ }
3283+
32333284
32343285/* Reproduce-first: Java module QN must derive from the CONTAINING DIRECTORY, not
32353286 * the filename stem, so a top-level class `Outer` in `Outer.java` is `t.Outer`,
@@ -5450,6 +5501,8 @@ SUITE(extraction) {
54505501 RUN_TEST (extract_java_method_annotations_issue382 );
54515502 RUN_TEST (extract_java_jaxrs_path_composition_issue1005 );
54525503 RUN_TEST (extract_ts_template_string_url_issue1006 );
5504+ RUN_TEST (extract_go_binary_concat_url_issue1249 );
5505+ RUN_TEST (extract_go_binary_concat_url_no_literal_suffix_issue1249 );
54535506 RUN_TEST (extract_java_no_double_class_qn );
54545507 RUN_TEST (extract_go_no_filename_in_module_qn );
54555508 RUN_TEST (extract_large_ts_has_functions_issue213 );
0 commit comments