Skip to content

Commit 38f7772

Browse files
authored
Fix regression from PR #2056: Allow whitespace in citation filenames (#2100)
1 parent e34edd5 commit 38f7772

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

app/frontend/src/components/Answer/AnswerParser.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type HtmlParsedAnswer = {
88

99
// Function to validate citation format and check if dataPoint starts with possible citation
1010
function isCitationValid(contextDataPoints: any, citationCandidate: string): boolean {
11-
const regex = /^[^\s]+\.[a-zA-Z0-9]+/;
11+
const regex = /.+\.\w{1,}(?:#\S*)?$/;
1212
if (!regex.test(citationCandidate)) {
1313
return false;
1414
}
@@ -23,13 +23,11 @@ function isCitationValid(contextDataPoints: any, citationCandidate: string): boo
2323
return false;
2424
}
2525

26-
const isValidCitation = dataPointsArray.some(dataPoint => dataPoint.startsWith(citationCandidate));
27-
28-
if (!isValidCitation) {
29-
return false;
30-
}
26+
const isValidCitation = dataPointsArray.some(dataPoint => {
27+
return dataPoint.startsWith(citationCandidate);
28+
});
3129

32-
return true;
30+
return isValidCitation;
3331
}
3432

3533
export function parseAnswerToHtml(answer: ChatAppResponse, isStreaming: boolean, onCitationClicked: (citationFilePath: string) => void): HtmlParsedAnswer {

0 commit comments

Comments
 (0)