File tree Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -278,15 +278,13 @@ async def install_inject_route(self) -> None:
278278 mapping = ImplToApiMapping()
279279
280280 async def route_handler(route: Route) -> None:
281- if route.request.resource_type == "document" and route.request.url.startswith("http"):
282- try:
283- response = await route.fetch(
284- # maxRedirects=0
285- )
286- await route.fulfill(response=response)
287- except:
281+ try:
282+ if route.request.resource_type == "document" and route.request.url.startswith("http"):
283+ protocol = route.request.url.split(":")[0]
284+ await route.continue_(url=f"{protocol}://patchright-init-script-inject.internal/")
285+ else:
288286 await route.continue_()
289- else :
287+ except :
290288 await route.continue_()
291289
292290 if not self.route_injecting:
@@ -334,15 +332,13 @@ async def install_inject_route(self) -> None:
334332 mapping = ImplToApiMapping()
335333
336334 async def route_handler(route: Route) -> None:
337- if route.request.resource_type == "document" and route.request.url.startswith("http"):
338- try:
339- response = await route.fetch(
340- # maxRedirects=0
341- )
342- await route.fulfill(response=response)
343- except Exception:
335+ try:
336+ if route.request.resource_type == "document" and route.request.url.startswith("http"):
337+ protocol = route.request.url.split(":")[0]
338+ await route.continue_(url=f"{protocol}://patchright-init-script-inject.internal/")
339+ else:
344340 await route.continue_()
345- else :
341+ except :
346342 await route.continue_()
347343
348344 if not self.route_injecting and not self.context.route_injecting:
You can’t perform that action at this time.
0 commit comments