From ed63ba4dcf53237d0166702481c0bcbbbaa4d9c8 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 10 Jul 2023 12:50:24 -0700 Subject: [PATCH] chore: roll 1.36.0-beta-1689010164000 (#1332) References #1311 --- README.md | 6 ++-- .../com/microsoft/playwright/impl/Utils.java | 15 ++++++-- .../microsoft/playwright/TestPageRoute.java | 36 +++++++++++++++++++ scripts/CLI_VERSION | 2 +- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2d433ff3..e60fe747 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 115.0.5790.56 | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| WebKit 16.4 | ✅ | ✅ | ✅ | -| Firefox 114.0.2 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Chromium 115.0.5790.75 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| WebKit 17.0 | ✅ | ✅ | ✅ | +| Firefox 115.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | Headless execution is supported for all the browsers on all platforms. Check out [system requirements](https://playwright.dev/java/docs/next/intro/#system-requirements) for details. diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/Utils.java b/playwright/src/main/java/com/microsoft/playwright/impl/Utils.java index 8200aa31..84f774c8 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/Utils.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/Utils.java @@ -89,7 +89,8 @@ class Utils { } - static Set escapeGlobChars = new HashSet<>(Arrays.asList('/', '$', '^', '+', '.', '(', ')', '=', '!', '|')); + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping + static Set escapeGlobChars = new HashSet<>(Arrays.asList('$', '^', '+', '.', '*', '(', ')', '|', '\\', '?', '{', '}', '[', ']')); static String globToRegex(String glob) { StringBuilder tokens = new StringBuilder(); @@ -97,8 +98,12 @@ class Utils { boolean inGroup = false; for (int i = 0; i < glob.length(); ++i) { char c = glob.charAt(i); - if (escapeGlobChars.contains(c)) { - tokens.append("\\").append(c); + if (c == '\\' && i + 1 < glob.length()) { + char nextChar = glob.charAt(++i); + if (escapeGlobChars.contains(nextChar)) { + tokens.append('\\'); + } + tokens.append(nextChar); continue; } if (c == '*') { @@ -139,7 +144,11 @@ class Utils { tokens.append("\\").append(c); break; default: + if (escapeGlobChars.contains(c)) { + tokens.append('\\'); + } tokens.append(c); + break; } } tokens.append('$'); diff --git a/playwright/src/test/java/com/microsoft/playwright/TestPageRoute.java b/playwright/src/test/java/com/microsoft/playwright/TestPageRoute.java index a8826f58..0fe4f75a 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestPageRoute.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestPageRoute.java @@ -97,6 +97,42 @@ public class TestPageRoute extends TestBase { assertEquals(asList(1), intercepted); } + @Test + void shouldSupportQuestionMarkInGlobPattern() { + server.setRoute("/index", exchange -> { + exchange.sendResponseHeaders(200, 0); + try (OutputStreamWriter writer = new OutputStreamWriter(exchange.getResponseBody())) { + writer.write("index-no-hello"); + } + }); + server.setRoute("/index123hello", exchange -> { + exchange.sendResponseHeaders(200, 0); + try (OutputStreamWriter writer = new OutputStreamWriter(exchange.getResponseBody())) { + writer.write("index123hello"); + } + }); + + page.route("**/index?hello", route -> { + route.fulfill(new Route.FulfillOptions().setBody("intercepted any character")); + }); + + page.route("**/index\\?hello", route -> { + route.fulfill(new Route.FulfillOptions().setBody("intercepted question mark")); + }); + + page.navigate(server.PREFIX + "/index?hello"); + assertTrue(page.content().contains("intercepted question mark"), page.content()); + + page.navigate(server.PREFIX + "/index"); + assertTrue(page.content().contains("index-no-hello"), page.content()); + + page.navigate(server.PREFIX + "/index1hello"); + assertTrue(page.content().contains("intercepted any character"), page.content()); + + page.navigate(server.PREFIX + "/index123hello"); + assertTrue(page.content().contains("index123hello"), page.content()); + } + @Test void shouldUnroutePredicate() { List intercepted = new ArrayList<>(); diff --git a/scripts/CLI_VERSION b/scripts/CLI_VERSION index 3d9836bb..122e0931 100644 --- a/scripts/CLI_VERSION +++ b/scripts/CLI_VERSION @@ -1 +1 @@ -1.36.0-alpha-jul-7-2023 +1.36.0-beta-1689010164000