Skip to content

Commit 2fdb89c

Browse files
authored
fix: match against updated url (#962)
1 parent 4fee61a commit 2fdb89c

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,6 @@ public String url() {
177177
if (fallbackOverrides != null && fallbackOverrides.url != null) {
178178
return fallbackOverrides.url;
179179
}
180-
return originalUrl();
181-
}
182-
183-
String originalUrl() {
184180
return initializer.get("url").getAsString();
185181
}
186182

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ boolean handle(RouteImpl route) {
4242
if (times != null && times <= 0) {
4343
return false;
4444
}
45-
if (!matcher.test(route.request().originalUrl())) {
45+
if (!matcher.test(route.request().url())) {
4646
return false;
4747
}
4848
if (times != null) {

playwright/src/test/java/com/microsoft/playwright/TestPageRequestFallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void shouldAmendMethod() throws ExecutionException, InterruptedException {
222222
void shouldOverrideRequestUrl() throws ExecutionException, InterruptedException {
223223
Future<Server.Request> request = server.futureRequest("/global-var.html");
224224
String[] url = {null};
225-
page.route("**/foo", route -> {
225+
page.route("**/global-var.html", route -> {
226226
url[0] = route.request().url();
227227
route.resume();
228228
});

playwright/src/test/java/com/microsoft/playwright/TestPageRoute.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,4 +725,25 @@ void shouldAddAccessControlAllowOriginByDefaultWhenFulfill() {
725725
});
726726
assertEquals(server.PREFIX, response.headerValue("Access-Control-Allow-Origin"));
727727
}
728+
729+
@Test
730+
void shouldChainFallbackWDynamicURL() {
731+
List<Integer> intercepted = new ArrayList<>();
732+
page.route("**/bar", route -> {
733+
intercepted.add(1);
734+
route.fallback(new Route.FallbackOptions().setUrl(server.EMPTY_PAGE));
735+
});
736+
page.route("**/foo", route -> {
737+
intercepted.add(2);
738+
route.fallback(new Route.FallbackOptions().setUrl("http://localhost/bar"));
739+
});
740+
741+
page.route("**/empty.html", route -> {
742+
intercepted.add(3);
743+
route.fallback(new Route.FallbackOptions().setUrl("http://localhost/foo"));
744+
});
745+
746+
page.navigate(server.EMPTY_PAGE);
747+
assertEquals(asList(3, 2, 1), intercepted);
748+
}
728749
}

0 commit comments

Comments
 (0)