fix search for real

This commit is contained in:
Your Name 2024-07-19 08:33:42 -04:00 committed by Henri Dickson
parent 9096df2da1
commit af0f4fa052
3 changed files with 4 additions and 3 deletions

View file

@ -29,6 +29,7 @@ SEARCHABLE_ATTRIBUTES = [
"pub_house",
"company",
"publisher",
"host",
"isbn",
"imdb",
"barcode",

View file

@ -114,7 +114,7 @@ def search(request):
except Exception:
categories = visible_categories(request)
tag = request.GET.get("tag", default="").strip()
tag = Tag.deep_cleanup_title(tag)
tag = Tag.deep_cleanup_title(tag, default="")
p = request.GET.get("page", default="1")
p = int(p) if p.isdigit() else 1
if not (keywords or tag):

View file

@ -59,9 +59,9 @@ class Tag(List):
return "_" if not t and replace else t
@staticmethod
def deep_cleanup_title(title):
def deep_cleanup_title(title, default="_"):
"""Remove all non-word characters, only for public index purpose"""
return re.sub(r"\W+", " ", title).rstrip().lstrip("# ").lower()[:100] or "_"
return re.sub(r"\W+", " ", title).rstrip().lstrip("# ").lower()[:100] or default
def update(
self, title: str, visibility: int | None = None, pinned: bool | None = None