url-encode paths in report linking

This commit is contained in:
I-Al-Istannen 2024-11-04 00:16:36 +01:00
parent f2b6f3bb00
commit c34cde519a
2 changed files with 4 additions and 1 deletions

View file

@ -24,6 +24,7 @@ ambiguous situations.
### Added ### Added
- Support for MOB videos in page descriptions - Support for MOB videos in page descriptions
- Clickable links in the report to directly open new/modified/not-deleted files
### Changed ### Changed
- Remove videos from description pages - Remove videos from description pages

View file

@ -1,5 +1,6 @@
from pathlib import Path, PurePath from pathlib import Path, PurePath
from typing import Dict, List, Optional from typing import Dict, List, Optional
from urllib.parse import quote
from rich.markup import escape from rich.markup import escape
@ -169,7 +170,8 @@ class Pferd:
log.report(f"[bold bright_cyan]Report[/] for {escape(name)}") log.report(f"[bold bright_cyan]Report[/] for {escape(name)}")
def fmt_path_link(relative_path: PurePath) -> str: def fmt_path_link(relative_path: PurePath) -> str:
link = f"file://{crawler.output_dir.resolve(relative_path).absolute()}" # We need to URL-encode the path because it might contain spaces or special characters
link = f"file://{quote(str(crawler.output_dir.resolve(relative_path).absolute()))}"
return f"[link={link}]{fmt_path(relative_path)}[/link]" return f"[link={link}]{fmt_path(relative_path)}[/link]"
something_changed = False something_changed = False