diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/mockserver/KeyValueInfo.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/mockserver/KeyValueInfo.java index 011a53b088..d059660aad 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/mockserver/KeyValueInfo.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/mockserver/KeyValueInfo.java @@ -5,7 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.apache.commons.lang3.StringUtils; -import java.util.regex.Matcher; import java.util.regex.Pattern; @Data @@ -56,10 +55,7 @@ public class KeyValueInfo { } } else if (StringUtils.equals(this.condition, ParamConditionEnums.REGULAR_MATCH.name())) { try { - Pattern pattern = Pattern.compile(value); - Matcher matcher = pattern.matcher(this.value); - boolean isMatch = matcher.matches(); - return isMatch; + return this.value.matches(Pattern.quote(value)); } catch (Exception e) { return false; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleRelationService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleRelationService.java index e256d25169..659cc67ca9 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleRelationService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserRoleRelationService.java @@ -139,15 +139,10 @@ public class UserRoleRelationService { for (UserRoleRelation userRoleRelation : userRoleRelationList) { Organization organization = organizationMapper.selectByPrimaryKey(userRoleRelation.getOrganizationId()); if (organization != null) { + returnMap.computeIfAbsent(organization, k -> new ArrayList<>()); Project project = projectMapper.selectByPrimaryKey(userRoleRelation.getSourceId()); if (project != null) { - if (returnMap.containsKey(organization)) { - if (!returnMap.get(organization).contains(project)) { - returnMap.get(organization).add(project); - } - } else { - returnMap.put(organization, new ArrayList<>(Arrays.asList(project))); - } + returnMap.get(organization).add(project); } } }