Skip to content

Commit

Permalink
fix(command line): markdown_root url
Browse files Browse the repository at this point in the history
- Fixes the path to correctly have `tree` in front of the `{branch}` for generating a correct URL.

- Fixes replacing `tree/` with `blob/HEAD` so that the generated URL does not have to define the default branch name in the case that `master` is not the default branch name.
  • Loading branch information
sambacha authored Jul 25, 2024
1 parent 9a5b4f5 commit 85a5836
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions slither/utils/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,15 @@ def check_and_sanitize_markdown_root(markdown_root: str) -> str:

if not match.group(4):
logger.warning(
"Appending 'master/tree/' in markdown_root url for better code referencing"
"Appending 'tree/master/' in markdown_root url for better code referencing"
)
markdown_root = markdown_root + "master/tree/"
markdown_root = markdown_root + "tree/master/"
# Use blob/HEAD so that we get the default branch regardless of its name
elif match.group(4) == "tree":
logger.warning(
"Replacing 'tree' with 'blob' in markdown_root url for better code referencing"
"Replacing 'tree' with 'blob/HEAD' in markdown_root url for better code referencing"
)
positions = match.span(4)
markdown_root = f"{markdown_root[:positions[0]]}blob{markdown_root[positions[1]:]}"
markdown_root = f"{markdown_root[:positions[0]]}blob/HEAD{markdown_root[positions[1]:]}"

return markdown_root

0 comments on commit 85a5836

Please sign in to comment.