[error info] 1. /\d+$/ will be matched, such as "xxx123".
2. `index = "xxx123".index('--') || "xxx123".rindex('-')` - index equal nil.
3. `r = r[0, nil]` - raise a TypeError.
Signed-off-by: Zhang Yuhang zhangyuhang25@huawei.com --- src/lib/web_backend.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/web_backend.rb b/src/lib/web_backend.rb index c3f6bef..55c5e4a 100644 --- a/src/lib/web_backend.rb +++ b/src/lib/web_backend.rb @@ -47,7 +47,7 @@ end def filter_tbox_group(es_result) result = Set.new es_result.each do |r| - if r =~ /(^.+--.+$)|(^vm-.*-\d\w*-([a-zA-Z]+)|(\d+)$)/ + if r =~ /(^.+--.+$)|(^vm-.*-\d\w*-(([a-zA-Z]+)|(\d+))$)/ index = r.index('--') || r.rindex('-') r = r[0, index] end
"area" 需要替换为实际的领域/模块/文件等等。。
Thanks, Fengguang
On Fri, Oct 30, 2020 at 04:56:44PM +0800, Zhang Yuhang wrote:
[error info]
/\d+$/ will be matched, such as "xxx123".
`index = "xxx123".index('--') || "xxx123".rindex('-')`
- index equal nil.
`r = r[0, nil]`
- raise a TypeError.
Signed-off-by: Zhang Yuhang zhangyuhang25@huawei.com
src/lib/web_backend.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/web_backend.rb b/src/lib/web_backend.rb index c3f6bef..55c5e4a 100644 --- a/src/lib/web_backend.rb +++ b/src/lib/web_backend.rb @@ -47,7 +47,7 @@ end def filter_tbox_group(es_result) result = Set.new es_result.each do |r|
- if r =~ /(^.+--.+$)|(^vm-.*-\d\w*-([a-zA-Z]+)|(\d+)$)/
- if r =~ /(^.+--.+$)|(^vm-.*-\d\w*-(([a-zA-Z]+)|(\d+))$)/ index = r.index('--') || r.rindex('-') r = r[0, index] end
-- 2.23.0