prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Localhost filter should consider affected URL
  Right now the "localhost" filter only consider's the affected User's IP: https://github.com/getsentry/sentry/blob/master/src/sentry/filters/localhost.py
  
  But users are also expecting that this should filter server errors triggered from a server running on localhost (e.g. local development).
  
  See also: #4729, #4762
  
  </issue>
  <code>
  [start of src/sentry/filters/localhost.py]
  1 from __future__ import absolute_import
  2 
  3 from .base import Filter
  4 
  5 LOCAL_IPS = frozenset(['127.0.0.1', '::1'])
  6 
  7 
  8 class LocalhostFilter(Filter):
  9     id = 'localhost'
  10     name = 'Filter out errors coming from localhost'
  11     description = 'This applies to to both IPv4 (``127.0.0.1``) and IPv6 (``::1``) addresses.'
  12 
  13     def get_ip_address(self, data):
  14         try:
  15             return data['sentry.interfaces.User']['ip_address']
  16         except KeyError:
  17             return ''
  18 
  19     def test(self, data):
  20         return self.get_ip_address(data) in LOCAL_IPS
  21
  [end of src/sentry/filters/localhost.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/sentry/filters/localhost.py b/src/sentry/filters/localhost.py
  --- a/src/sentry/filters/localhost.py
  +++ b/src/sentry/filters/localhost.py
  @@ -1,8 +1,10 @@
   from __future__ import absolute_import
   
   from .base import Filter
  +from six.moves.urllib.parse import urlparse
   
   LOCAL_IPS = frozenset(['127.0.0.1', '::1'])
  +LOCAL_DOMAINS = frozenset(['127.0.0.1', 'localhost'])
   
   
   class LocalhostFilter(Filter):
  @@ -16,5 +18,14 @@
           except KeyError:
               return ''
   
  +    def get_url(self, data):
  +        try:
  +            return data['sentry.interfaces.Http']['url'] or ''
  +        except KeyError:
  +            return ''
  +
  +    def get_domain(self, data):
  +        return urlparse(self.get_url(data)).netloc
  +
       def test(self, data):
  -        return self.get_ip_address(data) in LOCAL_IPS
  +        return self.get_ip_address(data) in LOCAL_IPS or self.get_domain(data) in LOCAL_DOMAINS
  
verification_info: {"golden_diff": "diff --git a/src/sentry/filters/localhost.py b/src/sentry/filters/localhost.py\n--- a/src/sentry/filters/localhost.py\n+++ b/src/sentry/filters/localhost.py\n@@ -1,8 +1,10 @@\n from __future__ import absolute_import\n \n from .base import Filter\n+from six.moves.urllib.parse import urlparse\n \n LOCAL_IPS = frozenset(['127.0.0.1', '::1'])\n+LOCAL_DOMAINS = frozenset(['127.0.0.1', 'localhost'])\n \n \n class LocalhostFilter(Filter):\n@@ -16,5 +18,14 @@\n         except KeyError:\n             return ''\n \n+    def get_url(self, data):\n+        try:\n+            return data['sentry.interfaces.Http']['url'] or ''\n+        except KeyError:\n+            return ''\n+\n+    def get_domain(self, data):\n+        return urlparse(self.get_url(data)).netloc\n+\n     def test(self, data):\n-        return self.get_ip_address(data) in LOCAL_IPS\n+        return self.get_ip_address(data) in LOCAL_IPS or self.get_domain(data) in LOCAL_DOMAINS\n", "issue": "Localhost filter should consider affected URL\nRight now the \"localhost\" filter only consider's the affected User's IP: https://github.com/getsentry/sentry/blob/master/src/sentry/filters/localhost.py\r\n\r\nBut users are also expecting that this should filter server errors triggered from a server running on localhost (e.g. local development).\r\n\r\nSee also: #4729, #4762\n", "before_files": [{"content": "from __future__ import absolute_import\n\nfrom .base import Filter\n\nLOCAL_IPS = frozenset(['127.0.0.1', '::1'])\n\n\nclass LocalhostFilter(Filter):\n    id = 'localhost'\n    name = 'Filter out errors coming from localhost'\n    description = 'This applies to to both IPv4 (``127.0.0.1``) and IPv6 (``::1``) addresses.'\n\n    def get_ip_address(self, data):\n        try:\n            return data['sentry.interfaces.User']['ip_address']\n        except KeyError:\n            return ''\n\n    def test(self, data):\n        return self.get_ip_address(data) in LOCAL_IPS\n", "path": "src/sentry/filters/localhost.py"}]}