作者 lyh

变更数据

@@ -1603,11 +1603,23 @@ if (!function_exists('httpGetSsl')) { @@ -1603,11 +1603,23 @@ if (!function_exists('httpGetSsl')) {
1603 } 1603 }
1604 // 先取前 $limit 个字符 1604 // 先取前 $limit 个字符
1605 $truncated = mb_substr($text, 0, $limit, 'UTF-8'); 1605 $truncated = mb_substr($text, 0, $limit, 'UTF-8');
  1606 + // 优先找空格
1606 $lastSpace = mb_strrpos($truncated, ' ', 0, 'UTF-8'); 1607 $lastSpace = mb_strrpos($truncated, ' ', 0, 'UTF-8');
1607 - if ($lastSpace !== false) {  
1608 - // 在最后一个空格处截断,避免英文单词被截断 1608 + if ($lastSpace === false) {
  1609 + // 如果没有空格,尝试找中横线或下划线(如英文连接符)
  1610 + $lastDash = max(
  1611 + (mb_strrpos($truncated, '-', 0, 'UTF-8') ?: 0),
  1612 + (mb_strrpos($truncated, '_', 0, 'UTF-8') ?: 0))
  1613 + ;
  1614 + if ($lastDash > 0) {
  1615 + $lastSpace = $lastDash;
  1616 + }
  1617 + }
  1618 + // 若找到合适位置则截断
  1619 + if ($lastSpace !== false && $lastSpace > 0) {
1609 $truncated = mb_substr($truncated, 0, $lastSpace, 'UTF-8'); 1620 $truncated = mb_substr($truncated, 0, $lastSpace, 'UTF-8');
1610 } 1621 }
1611 return $truncated; 1622 return $truncated;
1612 } 1623 }
  1624 +
1613 } 1625 }
@@ -85,7 +85,6 @@ class RouteMap extends Base @@ -85,7 +85,6 @@ class RouteMap extends Base
85 $length = strlen($sign); 85 $length = strlen($sign);
86 if($length > $route_len){ 86 if($length > $route_len){
87 $sign = truncate_text($sign,$route_len); 87 $sign = truncate_text($sign,$route_len);
88 - $sign = trim($sign,'-');  
89 } 88 }
90 $i=1;//路由重复时拼接 89 $i=1;//路由重复时拼接
91 $route = $sign.$suffix; 90 $route = $sign.$suffix;