Skip to content

Commit 991a866

Browse files
committed
documents' link generation: Make sure prefix ends with '/'
1 parent 255e1d0 commit 991a866

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pr_agent/tools/pr_help_docs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def aggregate_documentation_files_for_prompt_contents(base_path: str, doc_files:
101101

102102
def format_markdown_q_and_a_response(question_str: str, response_str: str, relevant_sections: List[Dict[str, str]],
103103
supported_suffixes: List[str], base_url_prefix: str, base_url_suffix: str="") -> str:
104+
base_url_prefix = base_url_prefix.strip('/') #Sanitize base_url_prefix
104105
answer_str = ""
105106
answer_str += f"### Question: \n{question_str}\n\n"
106107
answer_str += f"### Answer:\n{response_str.strip()}\n\n"
@@ -114,9 +115,9 @@ def format_markdown_q_and_a_response(question_str: str, response_str: str, relev
114115
if str(section['relevant_section_header_string']).strip():
115116
markdown_header = format_markdown_header(section['relevant_section_header_string'])
116117
if base_url_prefix:
117-
answer_str += f"> - {base_url_prefix}{file}{base_url_suffix}#{markdown_header}\n"
118+
answer_str += f"> - {base_url_prefix}/{file}{base_url_suffix}#{markdown_header}\n"
118119
else:
119-
answer_str += f"> - {base_url_prefix}{file}{base_url_suffix}\n"
120+
answer_str += f"> - {base_url_prefix}/{file}{base_url_suffix}\n"
120121
return answer_str
121122

122123
def format_markdown_header(header: str) -> str:

0 commit comments

Comments
 (0)