Skip to content

Commit 95bd5e0

Browse files
committed
Call removeprefix instead of lstrip
1 parent 21398e6 commit 95bd5e0

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

logya/content.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def filepath(base: Path, url: str) -> Path:
4444
If url does not end in a file name 'index.html' will be appended.
4545
"""
4646

47-
path = base / url.lstrip('/')
47+
path = base / url.removeprefix('/')
4848
if not path.suffix or path.suffix not in process_extensions:
4949
path = path / 'index.html'
5050
return path

logya/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def update_page(url: str, L: Logya) -> bool:
4444
def update_static(url: str, L: Logya) -> bool:
4545
"""Update static file if it was modified."""
4646

47-
url_rel = url.lstrip('/')
47+
url_rel = url.removeprefix('/')
4848
src_static = L.paths.static / url_rel
4949
if not src_static.is_file():
5050
return False

logya/template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def _filesource(root: Path, name: str, lines: int | None = None, raw: bool = Fal
4848
the source code used to render the current example.
4949
"""
5050

51-
# Call lstrip to prevent loading files outside the site directory.
52-
path_src = root / name.lstrip('/')
51+
# Remove leading / to prevent loading files outside the site directory.
52+
path_src = root / name.removeprefix('/')
5353
try:
5454
text = path_src.read_text()
5555
except UnicodeDecodeError:

0 commit comments

Comments
 (0)