diff --git a/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockApiUtils.java b/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockApiUtils.java index f439276034..9e312ba6b0 100644 --- a/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockApiUtils.java +++ b/api-test/backend/src/main/java/io/metersphere/commons/utils/mock/MockApiUtils.java @@ -753,9 +753,20 @@ public class MockApiUtils { return true; } } + // 去除URL中前缀后匹配 + return isPathMatchWithoutPrefix(path, url); } } } return false; } + + public static boolean isPathMatchWithoutPrefix(String path, String url) { + String pathNoProtocol = path.replaceAll("http[s]?://", ""); + int firstIndex = pathNoProtocol.indexOf("/"); + if (firstIndex > 0) { + pathNoProtocol = pathNoProtocol.substring(firstIndex); + } + return StringUtils.equalsAny(pathNoProtocol, url, "/" + url); + } }