From f59863ba70793a98460056d967f982ca457a6315 Mon Sep 17 00:00:00 2001 From: Jazzcort Date: Tue, 8 Jul 2025 09:35:16 -0400 Subject: [PATCH] Fix: add sanitizing process to strip off the trailing slash of the doc URL In this patch, we add a sanitizing process to strip off the trailing forward slash (if any) in the given URL before generating the file path for S3 bucket. Therefore, both variants (url with / and without /) in the config file can be treated the same. https://github.com/continuedev/continue/issues/6454 --- core/indexing/docs/DocsCache.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/indexing/docs/DocsCache.ts b/core/indexing/docs/DocsCache.ts index f250b797c..caa30139b 100644 --- a/core/indexing/docs/DocsCache.ts +++ b/core/indexing/docs/DocsCache.ts @@ -7,6 +7,15 @@ export interface SiteIndexingResults { title: string; } +/** + * Strip off the trailing forward slash from the given URL + * @param url The URL of the document + * @returns A sanitized URL without trailing forward slash + */ +const stripTrailingSlash = (url: string): string => { + return url.replace(/\/+$/, ""); +}; + export class DocsCache { static readonly AWS_REGION: string = "us-west-1"; static readonly BUCKET_NAME: string = "continue-preindexed-docs"; @@ -33,7 +42,8 @@ export class DocsCache { url: string, ): string { const normalizedEmbeddingId = DocsCache.normalizeEmbeddingId(embeddingId); - const normalizedUrl = encodeURIComponent(url.replace(/\//g, "_")); + const sanitizedUrl = stripTrailingSlash(url); + const normalizedUrl = encodeURIComponent(sanitizedUrl.replace(/\//g, "_")); return normalizedEmbeddingId + "/" + normalizedUrl; }