Skip to content

Commit

Permalink
Parse navigation buttons to avoid broken links
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Jan 28, 2024
1 parent eb0f3f4 commit 3a8cad3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pystream/models/squire.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import secrets
from typing import Dict, List, Tuple, Union
from urllib import parse as urlparse

from fastapi import Request
from fastapi.templating import Jinja2Templates
Expand Down Expand Up @@ -100,12 +101,12 @@ def get_iter(filename: pathlib.PurePath) -> Union[Tuple[str, str], Tuple[None, N
dir_content = sorted(os.listdir(filename.parent), key=lambda x: natural_sort_key(x))
idx = dir_content.index(filename.name)
try:
previous_ = dir_content[idx - 1]
previous_ = urlparse.quote(dir_content[idx - 1])
assert pathlib.PosixPath(previous_).suffix in config.env.file_formats
except (IndexError, AssertionError):
previous_ = None
try:
next_ = dir_content[idx + 1]
next_ = urlparse.quote(dir_content[idx + 1])
assert pathlib.PosixPath(next_).suffix in config.env.file_formats
except (IndexError, AssertionError):
next_ = None
Expand Down

0 comments on commit 3a8cad3

Please sign in to comment.