Skip to content

Commit c33e7ad

Browse files
factor out normalize_docs_path
1 parent f7d57ca commit c33e7ad

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/get_knowledge_base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ def parse_markdown_file_to_json(json_output, current_id, file_path):
140140

141141
def adjust_knowledge_base_entry_path(file_path):
142142
""" Adjusts the file path format for storage. """
143-
return re.sub(r'\/(\d{4})-(\d{2})-(\d{2})-', r'/\1/\2/\3/', file_path.replace("./.tmp/defang-docs", "").replace(".mdx", "").replace(".md", ""))
143+
return re.sub(r'\/(\d{4})-(\d{2})-(\d{2})-', r'/\1/\2/\3/', normalize_docs_path(file_path))
144+
145+
def normalize_docs_path(path):
146+
""" Normalizes the file path to ensure consistent formatting. """
147+
return path.replace("./.tmp/defang-docs", "").replace(".mdx", "").replace(".md", "")
144148

145149
def parse_cli_markdown(json_output, current_id, file_path):
146150
""" Parses CLI-specific markdown files """
@@ -164,7 +168,7 @@ def parse_cli_markdown(json_output, current_id, file_path):
164168
"id": current_id,
165169
"about": about,
166170
"text": text,
167-
"path": file_path.replace("./.tmp/defang-docs", "").replace(".mdx", "").replace(".md", "")
171+
"path": normalize_docs_path(file_path)
168172
})
169173

170174
def recursive_parse_directory(root_dir):

0 commit comments

Comments
 (0)