We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
L-function of Dirichlet character does not link to Dirichlet character page


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lmfdb/utils/names_and_urls.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 from lmfdb.utils.utilities import key_for_numerically_sort
3 from flask import url_for
4 #######################################################################
5 # Functions for interacting with web structure
6 #######################################################################
7 
8 # TODO This needs to be able to handle any sort of object
9 # There should probably be a more relevant field
10 # in the database, instead of trying to extract this from a URL
11 def name_and_object_from_url(url, check_existence=False):
12     # the import is here to avoid circular imports
13     from lmfdb import db
14     url_split = url.rstrip('/').lstrip('/').split("/")
15     name = '??'
16     obj_exists = False
17 
18     if url_split[0] == "EllipticCurve":
19         # every EC instance was added from EC
20         obj_exists = True
21         if url_split[1] == 'Q':
22             if len(url_split) == 4: # isogeny class
23                 # EllipticCurve/Q/341641/a
24                 label_isogeny_class = ".".join(url_split[-2:])
25                 if check_existence:
26                     obj_exists = db.ec_curvedata.exists({"lmfdb_iso": label_isogeny_class})
27             elif len(url_split) == 5: # curve
28                 # EllipticCurve/Q/48/a/6
29                 label_curve = ".".join(url_split[-3:-1]) + url_split[-1]
30                 if check_existence:
31                     obj_exists = db.ec_curvedata.exists({"lmfdb_label": label_curve})
32             else:
33                 raise NotImplementedError
34         else:
35             if len(url_split) == 4: # isogeny class
36                 # EllipticCurve/2.2.140.1/14.1/a
37                 field, cond, isog = url_split[-3:]
38                 label_isogeny_class = "-".join([field, cond, isog])
39                 if check_existence:
40                     obj_exists = db.ec_nfcurves.exists({"class_label": label_isogeny_class})
41             elif len(url_split) == 5: # curve
42                 # EllipticCurve/2.0.4.1/1250.3/a/3
43                 field, cond, isog, ind = url_split[-4:]
44                 label_curve = "-".join([field, cond, isog]) + ind
45                 if check_existence:
46                     obj_exists = db.ec_nfcurves.exists({"label": label_curve})
47         if len(url_split) == 4: # isogeny class
48             #name = 'Isogeny class ' + label_isogeny_class
49             name = 'Elliptic curve ' + label_isogeny_class
50         elif len(url_split) == 5: # curve
51             #name = 'Curve ' + label_curve
52             name = 'Elliptic curve ' + label_curve
53 
54     elif url_split[0] == "Genus2Curve":
55         obj_exists = True
56         assert url_split[1] == 'Q'
57         if len(url_split) == 4: # isog class
58             # Genus2Curve/Q/310329/a
59             label_isogeny_class = ".".join(url_split[-2:])
60             if check_existence:
61                 obj_exists = db.g2c_curves.exists({"class": label_isogeny_class})
62             #name = 'Isogeny class ' + label_isogeny_class
63             name = 'Genus 2 curve ' + label_isogeny_class
64         if len(url_split) == 6: # curve
65             # Genus2Curve/Q/1728/b/442368/1
66             label_curve = ".".join(url_split[-4:])
67             if check_existence:
68                 obj_exists = db.g2c_curves.exists({"label": label_curve})
69             #name = 'Curve ' + label_curve
70             name = 'Genus 2 curve ' + label_curve
71 
72     elif url_split[0] == "ModularForm":
73         if url_split[1] == 'GL2':
74             if url_split[2] == 'Q' and url_split[3]  == 'holomorphic':
75                 if len(url_split) == 10:
76                     # ModularForm/GL2/Q/holomorphic/24/2/f/a/11/2
77                     newform_label = ".".join(url_split[-6:-2])
78                     conrey_newform_label = ".".join(url_split[-6:])
79                     name = 'Modular form ' + conrey_newform_label
80                     obj_exists = True
81                     if check_existence:
82                         obj_exists = db.mf_newforms.label_exists(newform_label)
83                 elif len(url_split) == 8:
84                     # ModularForm/GL2/Q/holomorphic/24/2/f/a
85                     newform_label = ".".join(url_split[-4:])
86                     name = 'Modular form ' + newform_label
87                     obj_exists = True
88                     if check_existence:
89                         obj_exists = db.mf_newforms.label_exists(newform_label)
90 
91             elif url_split[2] == 'TotallyReal':
92                 # ModularForm/GL2/TotallyReal/2.2.140.1/holomorphic/2.2.140.1-14.1-a
93                 label = url_split[-1]
94                 name = 'Hilbert modular form ' + label
95                 obj_exists = True
96                 if check_existence:
97                     obj_exists = db.hmf_forms.label_exists(label)
98 
99             elif url_split[2] == 'ImaginaryQuadratic':
100                 # ModularForm/GL2/ImaginaryQuadratic/2.0.4.1/98.1/a
101                 label = '-'.join(url_split[-3:])
102                 name = 'Bianchi modular form ' + label
103                 obj_exists = 'CM' not in label
104                 if check_existence:
105                     obj_exists = db.bmf_forms.label_exists(label)
106     elif url_split[0] == "ArtinRepresentation":
107         label = url_split[1]
108         name = 'Artin representation ' + label
109         obj_exists = True
110         if check_existence:
111             obj_exists = db.artin_reps.label_exists(label.split('c')[0])
112     elif url_split[0] == "NumberField":
113         from lmfdb.number_fields.web_number_field import field_pretty
114         label = url_split[1]
115         name = 'Number field ' + field_pretty(label)
116         obj_exists = True
117         if check_existence:
118             obj_exists = db.number_fields.label_exists(label)
119     elif url_split[0] == "SatoTateGroup":
120         from lmfdb.sato_tate_groups.main import st_name
121         name, label = st_name(url_split[1])
122         if name is None:
123             name = label
124             obj_exists = False
125         else:
126             name = 'Sato Tate group $%s$' % name
127             obj_exists = True
128     else:
129         # FIXME
130         #print("unknown url", url)
131         pass
132 
133     return name, obj_exists
134 
135 
136 def names_and_urls(instances, exclude={}):
137     res = []
138     names = set()
139     urls = set()
140     exclude = set(exclude)
141     root = url_for('index')
142 
143     # remove duplicate urls
144     for instance in instances:
145         if not isinstance(instance, str):
146             instance = instance['url']
147         if instance not in exclude and '|' not in instance:
148             urls.add(instance)
149 
150     for url in urls:
151         name, obj_exists = name_and_object_from_url(url)
152         if not name:
153             name = ''
154         if obj_exists:
155             url = root + url
156         else:
157             # do not display unknown objects
158             continue
159             name = '(%s)' % (name)
160             url = ""
161         # avoid duplicates that might have arise from different instances
162         if name not in names:
163             res.append((name, url))
164             names.add(name)
165     # sort based on name + label
166     res.sort(key=lambda x: key_for_numerically_sort(x[0]))
167     return res
168
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/lmfdb/utils/names_and_urls.py b/lmfdb/utils/names_and_urls.py
--- a/lmfdb/utils/names_and_urls.py
+++ b/lmfdb/utils/names_and_urls.py
@@ -125,10 +125,14 @@
         else:
             name = 'Sato Tate group $%s$' % name
             obj_exists = True
+    elif url_split[:2] == ["Character", "Dirichlet"]:
+        modulus = int(url_split[2])
+        conrey = int(url_split[3])
+        name = "Character $\chi_{%d}(%d, \cdot)$" % (modulus, conrey)
+        obj_exists = True
     else:
         # FIXME
-        #print("unknown url", url)
-        pass
+        assert False, url
 
     return name, obj_exists

{"golden_diff": "diff --git a/lmfdb/utils/names_and_urls.py b/lmfdb/utils/names_and_urls.py\n--- a/lmfdb/utils/names_and_urls.py\n+++ b/lmfdb/utils/names_and_urls.py\n@@ -125,10 +125,14 @@\n         else:\n             name = 'Sato Tate group $%s$' % name\n             obj_exists = True\n+    elif url_split[:2] == [\"Character\", \"Dirichlet\"]:\n+        modulus = int(url_split[2])\n+        conrey = int(url_split[3])\n+        name = \"Character $\\chi_{%d}(%d, \\cdot)$\" % (modulus, conrey)\n+        obj_exists = True\n     else:\n         # FIXME\n-        #print(\"unknown url\", url)\n-        pass\n+        assert False, url\n \n     return name, obj_exists\n", "issue": "L-function of Dirichlet character does not link to Dirichlet character page\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nfrom lmfdb.utils.utilities import key_for_numerically_sort\nfrom flask import url_for\n#######################################################################\n# Functions for interacting with web structure\n#######################################################################\n\n# TODO This needs to be able to handle any sort of object\n# There should probably be a more relevant field\n# in the database, instead of trying to extract this from a URL\ndef name_and_object_from_url(url, check_existence=False):\n    # the import is here to avoid circular imports\n    from lmfdb import db\n    url_split = url.rstrip('/').lstrip('/').split(\"/\")\n    name = '??'\n    obj_exists = False\n\n    if url_split[0] == \"EllipticCurve\":\n        # every EC instance was added from EC\n        obj_exists = True\n        if url_split[1] == 'Q':\n            if len(url_split) == 4: # isogeny class\n                # EllipticCurve/Q/341641/a\n                label_isogeny_class = \".\".join(url_split[-2:])\n                if check_existence:\n                    obj_exists = db.ec_curvedata.exists({\"lmfdb_iso\": label_isogeny_class})\n            elif len(url_split) == 5: # curve\n                # EllipticCurve/Q/48/a/6\n                label_curve = \".\".join(url_split[-3:-1]) + url_split[-1]\n                if check_existence:\n                    obj_exists = db.ec_curvedata.exists({\"lmfdb_label\": label_curve})\n            else:\n                raise NotImplementedError\n        else:\n            if len(url_split) == 4: # isogeny class\n                # EllipticCurve/2.2.140.1/14.1/a\n                field, cond, isog = url_split[-3:]\n                label_isogeny_class = \"-\".join([field, cond, isog])\n                if check_existence:\n                    obj_exists = db.ec_nfcurves.exists({\"class_label\": label_isogeny_class})\n            elif len(url_split) == 5: # curve\n                # EllipticCurve/2.0.4.1/1250.3/a/3\n                field, cond, isog, ind = url_split[-4:]\n                label_curve = \"-\".join([field, cond, isog]) + ind\n                if check_existence:\n                    obj_exists = db.ec_nfcurves.exists({\"label\": label_curve})\n        if len(url_split) == 4: # isogeny class\n            #name = 'Isogeny class ' + label_isogeny_class\n            name = 'Elliptic curve ' + label_isogeny_class\n        elif len(url_split) == 5: # curve\n            #name = 'Curve ' + label_curve\n            name = 'Elliptic curve ' + label_curve\n\n    elif url_split[0] == \"Genus2Curve\":\n        obj_exists = True\n        assert url_split[1] == 'Q'\n        if len(url_split) == 4: # isog class\n            # Genus2Curve/Q/310329/a\n            label_isogeny_class = \".\".join(url_split[-2:])\n            if check_existence:\n                obj_exists = db.g2c_curves.exists({\"class\": label_isogeny_class})\n            #name = 'Isogeny class ' + label_isogeny_class\n            name = 'Genus 2 curve ' + label_isogeny_class\n        if len(url_split) == 6: # curve\n            # Genus2Curve/Q/1728/b/442368/1\n            label_curve = \".\".join(url_split[-4:])\n            if check_existence:\n                obj_exists = db.g2c_curves.exists({\"label\": label_curve})\n            #name = 'Curve ' + label_curve\n            name = 'Genus 2 curve ' + label_curve\n\n    elif url_split[0] == \"ModularForm\":\n        if url_split[1] == 'GL2':\n            if url_split[2] == 'Q' and url_split[3]  == 'holomorphic':\n                if len(url_split) == 10:\n                    # ModularForm/GL2/Q/holomorphic/24/2/f/a/11/2\n                    newform_label = \".\".join(url_split[-6:-2])\n                    conrey_newform_label = \".\".join(url_split[-6:])\n                    name = 'Modular form ' + conrey_newform_label\n                    obj_exists = True\n                    if check_existence:\n                        obj_exists = db.mf_newforms.label_exists(newform_label)\n                elif len(url_split) == 8:\n                    # ModularForm/GL2/Q/holomorphic/24/2/f/a\n                    newform_label = \".\".join(url_split[-4:])\n                    name = 'Modular form ' + newform_label\n                    obj_exists = True\n                    if check_existence:\n                        obj_exists = db.mf_newforms.label_exists(newform_label)\n\n            elif url_split[2] == 'TotallyReal':\n                # ModularForm/GL2/TotallyReal/2.2.140.1/holomorphic/2.2.140.1-14.1-a\n                label = url_split[-1]\n                name = 'Hilbert modular form ' + label\n                obj_exists = True\n                if check_existence:\n                    obj_exists = db.hmf_forms.label_exists(label)\n\n            elif url_split[2] == 'ImaginaryQuadratic':\n                # ModularForm/GL2/ImaginaryQuadratic/2.0.4.1/98.1/a\n                label = '-'.join(url_split[-3:])\n                name = 'Bianchi modular form ' + label\n                obj_exists = 'CM' not in label\n                if check_existence:\n                    obj_exists = db.bmf_forms.label_exists(label)\n    elif url_split[0] == \"ArtinRepresentation\":\n        label = url_split[1]\n        name = 'Artin representation ' + label\n        obj_exists = True\n        if check_existence:\n            obj_exists = db.artin_reps.label_exists(label.split('c')[0])\n    elif url_split[0] == \"NumberField\":\n        from lmfdb.number_fields.web_number_field import field_pretty\n        label = url_split[1]\n        name = 'Number field ' + field_pretty(label)\n        obj_exists = True\n        if check_existence:\n            obj_exists = db.number_fields.label_exists(label)\n    elif url_split[0] == \"SatoTateGroup\":\n        from lmfdb.sato_tate_groups.main import st_name\n        name, label = st_name(url_split[1])\n        if name is None:\n            name = label\n            obj_exists = False\n        else:\n            name = 'Sato Tate group $%s$' % name\n            obj_exists = True\n    else:\n        # FIXME\n        #print(\"unknown url\", url)\n        pass\n\n    return name, obj_exists\n\n\ndef names_and_urls(instances, exclude={}):\n    res = []\n    names = set()\n    urls = set()\n    exclude = set(exclude)\n    root = url_for('index')\n\n    # remove duplicate urls\n    for instance in instances:\n        if not isinstance(instance, str):\n            instance = instance['url']\n        if instance not in exclude and '|' not in instance:\n            urls.add(instance)\n\n    for url in urls:\n        name, obj_exists = name_and_object_from_url(url)\n        if not name:\n            name = ''\n        if obj_exists:\n            url = root + url\n        else:\n            # do not display unknown objects\n            continue\n            name = '(%s)' % (name)\n            url = \"\"\n        # avoid duplicates that might have arise from different instances\n        if name not in names:\n            res.append((name, url))\n            names.add(name)\n    # sort based on name + label\n    res.sort(key=lambda x: key_for_numerically_sort(x[0]))\n    return res\n", "path": "lmfdb/utils/names_and_urls.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nfrom lmfdb.utils.utilities import key_for_numerically_sort\nfrom flask import url_for\n#######################################################################\n# Functions for interacting with web structure\n#######################################################################\n\n# TODO This needs to be able to handle any sort of object\n# There should probably be a more relevant field\n# in the database, instead of trying to extract this from a URL\ndef name_and_object_from_url(url, check_existence=False):\n    # the import is here to avoid circular imports\n    from lmfdb import db\n    url_split = url.rstrip('/').lstrip('/').split(\"/\")\n    name = '??'\n    obj_exists = False\n\n    if url_split[0] == \"EllipticCurve\":\n        # every EC instance was added from EC\n        obj_exists = True\n        if url_split[1] == 'Q':\n            if len(url_split) == 4: # isogeny class\n                # EllipticCurve/Q/341641/a\n                label_isogeny_class = \".\".join(url_split[-2:])\n                if check_existence:\n                    obj_exists = db.ec_curvedata.exists({\"lmfdb_iso\": label_isogeny_class})\n            elif len(url_split) == 5: # curve\n                # EllipticCurve/Q/48/a/6\n                label_curve = \".\".join(url_split[-3:-1]) + url_split[-1]\n                if check_existence:\n                    obj_exists = db.ec_curvedata.exists({\"lmfdb_label\": label_curve})\n            else:\n                raise NotImplementedError\n        else:\n            if len(url_split) == 4: # isogeny class\n                # EllipticCurve/2.2.140.1/14.1/a\n                field, cond, isog = url_split[-3:]\n                label_isogeny_class = \"-\".join([field, cond, isog])\n                if check_existence:\n                    obj_exists = db.ec_nfcurves.exists({\"class_label\": label_isogeny_class})\n            elif len(url_split) == 5: # curve\n                # EllipticCurve/2.0.4.1/1250.3/a/3\n                field, cond, isog, ind = url_split[-4:]\n                label_curve = \"-\".join([field, cond, isog]) + ind\n                if check_existence:\n                    obj_exists = db.ec_nfcurves.exists({\"label\": label_curve})\n        if len(url_split) == 4: # isogeny class\n            #name = 'Isogeny class ' + label_isogeny_class\n            name = 'Elliptic curve ' + label_isogeny_class\n        elif len(url_split) == 5: # curve\n            #name = 'Curve ' + label_curve\n            name = 'Elliptic curve ' + label_curve\n\n    elif url_split[0] == \"Genus2Curve\":\n        obj_exists = True\n        assert url_split[1] == 'Q'\n        if len(url_split) == 4: # isog class\n            # Genus2Curve/Q/310329/a\n            label_isogeny_class = \".\".join(url_split[-2:])\n            if check_existence:\n                obj_exists = db.g2c_curves.exists({\"class\": label_isogeny_class})\n            #name = 'Isogeny class ' + label_isogeny_class\n            name = 'Genus 2 curve ' + label_isogeny_class\n        if len(url_split) == 6: # curve\n            # Genus2Curve/Q/1728/b/442368/1\n            label_curve = \".\".join(url_split[-4:])\n            if check_existence:\n                obj_exists = db.g2c_curves.exists({\"label\": label_curve})\n            #name = 'Curve ' + label_curve\n            name = 'Genus 2 curve ' + label_curve\n\n    elif url_split[0] == \"ModularForm\":\n        if url_split[1] == 'GL2':\n            if url_split[2] == 'Q' and url_split[3]  == 'holomorphic':\n                if len(url_split) == 10:\n                    # ModularForm/GL2/Q/holomorphic/24/2/f/a/11/2\n                    newform_label = \".\".join(url_split[-6:-2])\n                    conrey_newform_label = \".\".join(url_split[-6:])\n                    name = 'Modular form ' + conrey_newform_label\n                    obj_exists = True\n                    if check_existence:\n                        obj_exists = db.mf_newforms.label_exists(newform_label)\n                elif len(url_split) == 8:\n                    # ModularForm/GL2/Q/holomorphic/24/2/f/a\n                    newform_label = \".\".join(url_split[-4:])\n                    name = 'Modular form ' + newform_label\n                    obj_exists = True\n                    if check_existence:\n                        obj_exists = db.mf_newforms.label_exists(newform_label)\n\n            elif url_split[2] == 'TotallyReal':\n                # ModularForm/GL2/TotallyReal/2.2.140.1/holomorphic/2.2.140.1-14.1-a\n                label = url_split[-1]\n                name = 'Hilbert modular form ' + label\n                obj_exists = True\n                if check_existence:\n                    obj_exists = db.hmf_forms.label_exists(label)\n\n            elif url_split[2] == 'ImaginaryQuadratic':\n                # ModularForm/GL2/ImaginaryQuadratic/2.0.4.1/98.1/a\n                label = '-'.join(url_split[-3:])\n                name = 'Bianchi modular form ' + label\n                obj_exists = 'CM' not in label\n                if check_existence:\n                    obj_exists = db.bmf_forms.label_exists(label)\n    elif url_split[0] == \"ArtinRepresentation\":\n        label = url_split[1]\n        name = 'Artin representation ' + label\n        obj_exists = True\n        if check_existence:\n            obj_exists = db.artin_reps.label_exists(label.split('c')[0])\n    elif url_split[0] == \"NumberField\":\n        from lmfdb.number_fields.web_number_field import field_pretty\n        label = url_split[1]\n        name = 'Number field ' + field_pretty(label)\n        obj_exists = True\n        if check_existence:\n            obj_exists = db.number_fields.label_exists(label)\n    elif url_split[0] == \"SatoTateGroup\":\n        from lmfdb.sato_tate_groups.main import st_name\n        name, label = st_name(url_split[1])\n        if name is None:\n            name = label\n            obj_exists = False\n        else:\n            name = 'Sato Tate group $%s$' % name\n            obj_exists = True\n    elif url_split[:2] == [\"Character\", \"Dirichlet\"]:\n        modulus = int(url_split[2])\n        conrey = int(url_split[3])\n        name = \"Character $\\chi_{%d}(%d, \\cdot)$\" % (modulus, conrey)\n        obj_exists = True\n    else:\n        # FIXME\n        assert False, url\n\n    return name, obj_exists\n\n\ndef names_and_urls(instances, exclude={}):\n    res = []\n    names = set()\n    urls = set()\n    exclude = set(exclude)\n    root = url_for('index')\n\n    # remove duplicate urls\n    for instance in instances:\n        if not isinstance(instance, str):\n            instance = instance['url']\n        if instance not in exclude and '|' not in instance:\n            urls.add(instance)\n\n    for url in urls:\n        name, obj_exists = name_and_object_from_url(url)\n        if not name:\n            name = ''\n        if obj_exists:\n            url = root + url\n        else:\n            # do not display unknown objects\n            continue\n            name = '(%s)' % (name)\n            url = \"\"\n        # avoid duplicates that might have arise from different instances\n        if name not in names:\n            res.append((name, url))\n            names.add(name)\n    # sort based on name + label\n    res.sort(key=lambda x: key_for_numerically_sort(x[0]))\n    return res\n", "path": "lmfdb/utils/names_and_urls.py"}]}