@@ -56,19 +56,18 @@ public static TrieNode<String> buildSimpleApiTrieNode(String[] apiPathInfoList)
5656 // 因为前端的改动(最初的 tagValue 只有 path,某次前端组件改动后变成了 path-method,非客户提的),有兼容性问题,
5757 // 临时简化处理,不处理 method,前面逻辑保留是为了取出正确的 path
5858 method = null ;
59- String [] apiPaths = path .split ("/" );
60-
61- // 跳过第一个为空的str
6259 TrieNode <String > node = root ;
63- // 一些场景下(例如dubbo的接口名是com.tencent.polaris.serviceName),apiPath 不以"/"开头和分割,则直接构造node
64- if (apiPaths .length == 1 ) {
65- node = node .getOrCreateSubNode (apiPaths [0 ]);
60+ // 一些场景下apiPath 不以"/"开头和分割(
61+ // 此时方法标识符的格式规定为 '{类路径}#{方法名}' 例如com.tencent.polaris.ServiceName#sayHello
62+ if (path .contains ("#" )) {
63+ node = node .getOrCreateSubNode (path );
6664 node .setNodeInfo (TrieNode .SIMPLE_VALID_INFO + "method:" + method );
6765 continue ;
6866 }
67+ String [] apiPaths = path .split ("/" );
68+ // 跳过第一个为空的str
6969 for (int i = 1 ; i < apiPaths .length ; i ++) {
7070 node = node .getOrCreateSubNode (apiPaths [i ]);
71-
7271 // 叶子节点,需要 info
7372 if (i == apiPaths .length - 1 ) {
7473 node .setNodeInfo (TrieNode .SIMPLE_VALID_INFO + "method:" + method );
@@ -90,18 +89,21 @@ public static boolean checkSimpleApi(TrieNode<String> root, String apiPathInfo)
9089 } else {
9190 method = null ;
9291 }
93- String [] apiPaths = path . split ( "/" );
92+
9493
9594 TrieNode <String > node = root ;
96- // 一些场景下(例如dubbo的接口名是com.tencent.polaris.serviceName),apiPath 不以"/"开头和分割,则直接构造node
97- if (apiPaths .length == 1 ) {
98- node = node .getOrCreateSubNode (apiPaths [0 ]);
95+ // 一些场景下apiPath 不以"/"开头和分割(
96+ // 此时方法标识符的格式规定为 '{类路径}#{方法名}' 例如com.tencent.polaris.ServiceName#sayHello
97+ if (apiPathInfo .contains ("#" )){
98+ node = node .getOrCreateSubNode (apiPathInfo );
9999 if (node == null ) {
100100 return false ;
101101 } else {
102102 return checkApiNodeInfo (node , method );
103103 }
104104 }
105+
106+ String [] apiPaths = path .split ("/" );
105107 for (int i = 1 ; i < apiPaths .length ; i ++) {
106108 if (node == null ) {
107109 return false ;
0 commit comments