prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Return secure URLs for the fields thumbnail, detail_url and related_url.
  _(Framed the verbiage of the title as a feature request)_ 🙏 
  
  ## Problem
  
  The response for search and detail requests includes insecure URLs (`http` instead of `https`) in the fields `thumbnail`, `detail_url` and `related_url`.
  
  ![image](https://user-images.githubusercontent.com/746152/158834288-6b49c399-3b8c-48c8-8529-cdff970686a3.png)
  
  
  e.g.:
  
  **Search**
  
  https://api.openverse.engineering/v1/images/?q=flower
  
  **Detail:**
  
  https://api.openverse.engineering/v1/images/6c1769b0-a3e5-4dae-8a36-8531a6e1430f/
  
  ## Description
  
  When trying to integrate Openverse with some code on the browser I ended up having to replace the scheme part of the URL for avoiding notices like ```xxxx was loaded over HTTPS, but requested an insecure resource 'http://api.openverse.engineering/v1/images/6c1769b0-a3e5-4dae-8a36-8531a6e1430f/'. This request has been blocked; the content must be served over HTTPS.`
   
  
  
  </issue>
  <code>
  [start of api/catalog/api/serializers/base.py]
  1 import re
  2 
  3 from django.conf import settings
  4 from rest_framework import serializers
  5 
  6 
  7 class SchemableHyperlinkedIdentityField(serializers.HyperlinkedIdentityField):
  8     """
  9     This field returns the link but allows the option to replace the URL scheme.
  10     """
  11 
  12     def __init__(self, scheme=settings.API_LINK_SCHEME, *args, **kwargs):
  13         super().__init__(*args, **kwargs)
  14 
  15         self.scheme = scheme
  16 
  17     def get_url(self, *args, **kwargs):
  18         url = super().get_url(*args, **kwargs)
  19 
  20         # Only rewrite URLs if a fixed scheme is provided
  21         if self.scheme is not None:
  22             re.sub(r"^\w+://", f"{self.scheme}://", url, 1)
  23 
  24         return url
  25
  [end of api/catalog/api/serializers/base.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/api/catalog/api/serializers/base.py b/api/catalog/api/serializers/base.py
  --- a/api/catalog/api/serializers/base.py
  +++ b/api/catalog/api/serializers/base.py
  @@ -19,6 +19,6 @@
   
           # Only rewrite URLs if a fixed scheme is provided
           if self.scheme is not None:
  -            re.sub(r"^\w+://", f"{self.scheme}://", url, 1)
  +            url = re.sub(r"^\w+://", f"{self.scheme}://", url, 1)
   
           return url
  
verification_info: {"golden_diff": "diff --git a/api/catalog/api/serializers/base.py b/api/catalog/api/serializers/base.py\n--- a/api/catalog/api/serializers/base.py\n+++ b/api/catalog/api/serializers/base.py\n@@ -19,6 +19,6 @@\n \n         # Only rewrite URLs if a fixed scheme is provided\n         if self.scheme is not None:\n-            re.sub(r\"^\\w+://\", f\"{self.scheme}://\", url, 1)\n+            url = re.sub(r\"^\\w+://\", f\"{self.scheme}://\", url, 1)\n \n         return url\n", "issue": "Return secure URLs for the fields thumbnail, detail_url and related_url.\n_(Framed the verbiage of the title as a feature request)_ \ud83d\ude4f \r\n\r\n## Problem\r\n\r\nThe response for search and detail requests includes insecure URLs (`http` instead of `https`) in the fields `thumbnail`, `detail_url` and `related_url`.\r\n\r\n![image](https://user-images.githubusercontent.com/746152/158834288-6b49c399-3b8c-48c8-8529-cdff970686a3.png)\r\n\r\n\r\ne.g.:\r\n\r\n**Search**\r\n\r\nhttps://api.openverse.engineering/v1/images/?q=flower\r\n\r\n**Detail:**\r\n\r\nhttps://api.openverse.engineering/v1/images/6c1769b0-a3e5-4dae-8a36-8531a6e1430f/\r\n\r\n## Description\r\n\r\nWhen trying to integrate Openverse with some code on the browser I ended up having to replace the scheme part of the URL for avoiding notices like ```xxxx was loaded over HTTPS, but requested an insecure resource 'http://api.openverse.engineering/v1/images/6c1769b0-a3e5-4dae-8a36-8531a6e1430f/'. This request has been blocked; the content must be served over HTTPS.`\r\n \r\n\n", "before_files": [{"content": "import re\n\nfrom django.conf import settings\nfrom rest_framework import serializers\n\n\nclass SchemableHyperlinkedIdentityField(serializers.HyperlinkedIdentityField):\n    \"\"\"\n    This field returns the link but allows the option to replace the URL scheme.\n    \"\"\"\n\n    def __init__(self, scheme=settings.API_LINK_SCHEME, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        self.scheme = scheme\n\n    def get_url(self, *args, **kwargs):\n        url = super().get_url(*args, **kwargs)\n\n        # Only rewrite URLs if a fixed scheme is provided\n        if self.scheme is not None:\n            re.sub(r\"^\\w+://\", f\"{self.scheme}://\", url, 1)\n\n        return url\n", "path": "api/catalog/api/serializers/base.py"}]}