Merge pull request #6512 from Jazzcort/sanitize-doc-url
Fix: add sanitizing process to strip off the trailing slash of the doc URL
This commit is contained in:
commit
33d44cd540
1 changed files with 11 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue