MCPcopy
hub / github.com/reflex-dev/reflex / _get_lighthouse_target_url

Function _get_lighthouse_target_url

tests/integration/lighthouse_utils.py:774–806  ·  view source on GitHub ↗

Convert bind-all URLs into loopback URLs that browser clients can reach. Args: url: The reported frontend URL. Returns: A client-reachable URL for Lighthouse.

(url: str)

Source from the content-addressed store, hash-verified

772
773
774def _get_lighthouse_target_url(url: str) -> str:
775 """Convert bind-all URLs into loopback URLs that browser clients can reach.
776
777 Args:
778 url: The reported frontend URL.
779
780 Returns:
781 A client-reachable URL for Lighthouse.
782 """
783 parsed = urlsplit(url)
784 replacement_host = {
785 "0.0.0.0": "127.0.0.1",
786 "::": "::1",
787 }.get(parsed.hostname or "")
788 if replacement_host is None:
789 return url
790
791 auth = ""
792 if parsed.username is not None:
793 auth = parsed.username
794 if parsed.password is not None:
795 auth += f":{parsed.password}"
796 auth += "@"
797
798 host = replacement_host
799 if ":" in host:
800 host = f"[{host}]"
801
802 netloc = f"{auth}{host}"
803 if parsed.port is not None:
804 netloc = f"{netloc}:{parsed.port}"
805
806 return urlunsplit(parsed._replace(netloc=netloc))
807
808
809def get_chrome_path() -> str:

Callers 1

Calls 2

getMethod · 0.45
_replaceMethod · 0.45

Tested by

no test coverage detected