Skip to content

Commit bb34b26

Browse files
committed
fix globToRegex
1 parent 5f24578 commit bb34b26

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

playwright/src/main/java/com/microsoft/playwright/impl/LocalUtils.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,13 @@ String tracingStarted(String tracesDir, String traceName) {
6161
return json.get("stacksId").getAsString();
6262
}
6363

64-
Pattern globToRegex(String glob, String baseUrl, String websocketUrl) {
64+
Pattern globToRegex(String glob, String baseURL, boolean webSocketUrl) {
6565
JsonObject params = new JsonObject();
6666
params.addProperty("glob", glob);
67-
if (baseUrl != null) {
68-
params.addProperty("baseUrl", baseUrl);
69-
}
70-
if (websocketUrl != null) {
71-
params.addProperty("websocketUrl", websocketUrl);
67+
if (baseURL != null) {
68+
params.addProperty("baseURL", baseURL);
7269
}
70+
params.addProperty("webSocketUrl", webSocketUrl);
7371
JsonObject json = connection.localUtils().sendMessage("globToRegex", params).getAsJsonObject();
7472
return Pattern.compile(json.get("regex").getAsString());
7573
}

playwright/src/main/java/com/microsoft/playwright/impl/UrlMatcher.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,22 @@ private UrlMatcher(LocalUtils localUtils, URL baseURL, String glob, Pattern patt
8686
}
8787

8888
boolean test(String value) {
89-
return testImpl(localUtils, baseURL, pattern, predicate, glob, value);
89+
return testImpl(localUtils, baseURL, pattern, predicate, glob, value, false);
9090
}
9191

92-
private static boolean testImpl(LocalUtils localUtils, String baseURL, Pattern pattern, Predicate<String> predicate, String glob, String value) {
92+
boolean testWebsocket(String value) {
93+
return testImpl(localUtils, baseURL, pattern, predicate, glob, value, true);
94+
}
95+
96+
private static boolean testImpl(LocalUtils localUtils, String baseURL, Pattern pattern, Predicate<String> predicate, String glob, String value, boolean isWebSocket) {
9397
if (pattern != null) {
9498
return pattern.matcher(value).find();
9599
}
96100
if (predicate != null) {
97101
return predicate.test(value);
98102
}
99103
if (glob != null) {
100-
return localUtils.globToRegex(glob, baseURL, null).matcher(value).find();
104+
return localUtils.globToRegex(glob, baseURL, isWebSocket).matcher(value).find();
101105
}
102106
return true;
103107
}

playwright/src/main/java/com/microsoft/playwright/impl/WebSocketRouter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void add(UrlMatcher matcher, Consumer<WebSocketRoute> handler) {
3232

3333
boolean handle(WebSocketRouteImpl route) {
3434
for (RouteInfo routeInfo: routes) {
35-
if (routeInfo.matcher.test(route.url())) {
35+
if (routeInfo.matcher.testWebsocket(route.url())) {
3636
routeInfo.handle(route);
3737
return true;
3838
}

0 commit comments

Comments
 (0)