From 329824ab22ce3a68321d7244fe2fca83262c9633 Mon Sep 17 00:00:00 2001 From: Weves Date: Thu, 2 Nov 2023 21:48:55 -0700 Subject: [PATCH] Address issue with links for Google Sites connector --- backend/danswer/connectors/google_site/connector.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/danswer/connectors/google_site/connector.py b/backend/danswer/connectors/google_site/connector.py index c92040cbb95..6a11bee16f8 100644 --- a/backend/danswer/connectors/google_site/connector.py +++ b/backend/danswer/connectors/google_site/connector.py @@ -1,4 +1,5 @@ import os +import re import urllib.parse from typing import Any from typing import cast @@ -29,7 +30,9 @@ def process_link(element: BeautifulSoup | Tag) -> str: href = urllib.parse.unquote(href) href = href.rstrip(".html").lower() href = href.replace("_", "") - href = href.replace(" ", "-") + href = re.sub( + r"([\s-]+)", "-", href + ) # replace all whitespace/'-' groups with a single '-' return href