Skip to content

Commit

Permalink
chore: roll 1.36.0-beta-1689010164000 (#1332)
Browse files Browse the repository at this point in the history
References #1311
  • Loading branch information
yury-s authored Jul 10, 2023
1 parent 48a92d1 commit ed63ba4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->115.0.5790.56<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->16.4<!-- GEN:stop --> ||||
| Firefox <!-- GEN:firefox-version -->114.0.2<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->115.0.5790.75<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->17.0<!-- GEN:stop --> ||||
| Firefox <!-- GEN:firefox-version -->115.0<!-- GEN:stop --> | :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.

Expand Down
15 changes: 12 additions & 3 deletions playwright/src/main/java/com/microsoft/playwright/impl/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,21 @@ static <T> T clone(T f) {
}


static Set<Character> escapeGlobChars = new HashSet<>(Arrays.asList('/', '$', '^', '+', '.', '(', ')', '=', '!', '|'));
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping
static Set<Character> escapeGlobChars = new HashSet<>(Arrays.asList('$', '^', '+', '.', '*', '(', ')', '|', '\\', '?', '{', '}', '[', ']'));

static String globToRegex(String glob) {
StringBuilder tokens = new StringBuilder();
tokens.append('^');
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 == '*') {
Expand Down Expand Up @@ -139,7 +144,11 @@ static String globToRegex(String glob) {
tokens.append("\\").append(c);
break;
default:
if (escapeGlobChars.contains(c)) {
tokens.append('\\');
}
tokens.append(c);
break;
}
}
tokens.append('$');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,42 @@ void shouldUnroute() {
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<Integer> intercepted = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion scripts/CLI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.36.0-alpha-jul-7-2023
1.36.0-beta-1689010164000

0 comments on commit ed63ba4

Please sign in to comment.