Uh oh!
There was an error while loading. Please reload this page.
fix(glob): throw on page.route() for unbalanced braces in glob patterns - #40442
fix(glob): throw on page.route() for unbalanced braces in glob patterns#40442Thavamani Murugan (Thavamani13) wants to merge 2 commits into
Conversation
Validates glob patterns eagerly in RouteHandler and WebSocketRouteHandler
constructors so an invalid pattern like '{foo' throws immediately when
page.route() / context.route() is called, rather than silently aborting
requests at match time via a SyntaxError from new RegExp().
Fixes: microsoft#40422| constructor(baseURL: string | undefined, url: URLMatch, handler: WebSocketRouteHandlerCallback) { | ||
| this._baseURL = baseURL; | ||
| this.url = url; | ||
| if (isString(url)) |
There was a problem hiding this comment.
let's move this to the dispatcher / server side, so it also applies to our language ports.
There was a problem hiding this comment.
Moved it Simon Knott (@Skn0tt) Please check
Move glob pattern validation from the client-side WebSocketRouteHandler constructor to setWebSocketInterceptionPatterns in both BrowserContext and Page dispatchers, so the error also surfaces for language ports.
Test results for "tests 1"9 flaky41467 passed, 847 skipped Merge workflow run. |
Test results for "MCP"1 failed 6651 passed, 927 skipped Merge workflow run. |
| this._baseURL = baseURL; | ||
| this._times = times; | ||
| this.url = url; | ||
| if (isString(url)) |
There was a problem hiding this comment.
_updateInterceptionPatterns is called next line at both constructions sites and it does the glob validation on the server, do we still need to duplicate the logic here?
I'll close it for #40614. We assign trivial issues to copilot, no need to send the PRs (see contributors' guide) |
Summary
globToRegexPattern()now throws a descriptive error for nested{, unmatched}, and unclosed{RouteHandlerandWebSocketRouteHandlerconstructors callresolveGlobToRegexPattern()eagerly so the error surfaces immediately whenpage.route()/context.route()is called, not silently at request-match timeFixes#40422