fix: normalize url (#76)

This commit is contained in:
Vlad Stan 2025-03-03 14:34:46 +02:00 committed by GitHub
commit 218df89948
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 871 additions and 666 deletions

View file

@ -2,6 +2,7 @@ import json
from typing import Optional
from fastapi import Query, Request
from lnbits.helpers import normalize_path
from lnurl import encode as lnurl_encode
from lnurl.types import LnurlPayMetadata
from pydantic import BaseModel
@ -61,6 +62,7 @@ class PayLink(BaseModel):
def lnurl(self, req: Request) -> str:
url = req.url_for("lnurlp.api_lnurl_response", link_id=self.id)
url = url.replace(path=normalize_path(url.path))
url_str = str(url)
if url.netloc.endswith(".onion"):
# change url string scheme to http