Use Python facilities to convert paths to file:// urls

This commit is contained in:
I-Al-Istannen
2024-11-14 20:06:13 +01:00
parent 287173b0b1
commit 678283d341
2 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,5 @@
from pathlib import Path, PurePath
from typing import Dict, List, Optional
from urllib.parse import quote
from rich.markup import escape
@ -171,7 +170,7 @@ class Pferd:
def fmt_path_link(relative_path: PurePath) -> str:
# 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()))}"
link = crawler.output_dir.resolve(relative_path).absolute().as_uri()
return f"[link={link}]{fmt_path(relative_path)}[/link]"
something_changed = False