Skip to content

Commit 8e9020d

Browse files
factor out normalize_docs_path
1 parent 482901f commit 8e9020d

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
@@ -141,7 +141,11 @@ def parse_markdown_file_to_json(json_output, current_id, file_path):
141141

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

146150
def parse_cli_markdown(json_output, current_id, file_path):
147151
""" Parses CLI-specific markdown files """
@@ -165,7 +169,7 @@ def parse_cli_markdown(json_output, current_id, file_path):
165169
"id": current_id,
166170
"about": about,
167171
"text": text,
168-
"path": file_path.replace("./.tmp/defang-docs", "").replace(".mdx", "").replace(".md", "")
172+
"path": normalize_docs_path(file_path)
169173
})
170174

171175
def recursive_parse_directory(root_dir):

0 commit comments

Comments
 (0)