fix: normalize url (#76)
This commit is contained in:
parent
1d66d2f536
commit
218df89948
4 changed files with 871 additions and 666 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Pay Links",
|
"name": "Pay Links",
|
||||||
|
"version": "1.0.1",
|
||||||
"short_description": "Make reusable LNURL pay links",
|
"short_description": "Make reusable LNURL pay links",
|
||||||
"tile": "/lnurlp/static/image/lnurl-pay.png",
|
"tile": "/lnurlp/static/image/lnurl-pay.png",
|
||||||
"min_lnbits_version": "1.0.0",
|
"min_lnbits_version": "1.0.0",
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import json
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from fastapi import Query, Request
|
from fastapi import Query, Request
|
||||||
|
from lnbits.helpers import normalize_path
|
||||||
from lnurl import encode as lnurl_encode
|
from lnurl import encode as lnurl_encode
|
||||||
from lnurl.types import LnurlPayMetadata
|
from lnurl.types import LnurlPayMetadata
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
@ -61,6 +62,7 @@ class PayLink(BaseModel):
|
||||||
|
|
||||||
def lnurl(self, req: Request) -> str:
|
def lnurl(self, req: Request) -> str:
|
||||||
url = req.url_for("lnurlp.api_lnurl_response", link_id=self.id)
|
url = req.url_for("lnurlp.api_lnurl_response", link_id=self.id)
|
||||||
|
url = url.replace(path=normalize_path(url.path))
|
||||||
url_str = str(url)
|
url_str = str(url)
|
||||||
if url.netloc.endswith(".onion"):
|
if url.netloc.endswith(".onion"):
|
||||||
# change url string scheme to http
|
# change url string scheme to http
|
||||||
|
|
|
||||||
1530
poetry.lock
generated
1530
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -3,6 +3,7 @@ from typing import Optional, Union
|
||||||
|
|
||||||
from fastapi import APIRouter, HTTPException, Query, Request
|
from fastapi import APIRouter, HTTPException, Query, Request
|
||||||
from lnbits.core.services import create_invoice
|
from lnbits.core.services import create_invoice
|
||||||
|
from lnbits.helpers import normalize_path
|
||||||
from lnbits.utils.exchange_rates import get_fiat_rate_satoshis
|
from lnbits.utils.exchange_rates import get_fiat_rate_satoshis
|
||||||
from lnurl import LnurlErrorResponse, LnurlPayActionResponse, LnurlPayResponse
|
from lnurl import LnurlErrorResponse, LnurlPayActionResponse, LnurlPayResponse
|
||||||
from lnurl.models import MessageAction, UrlAction
|
from lnurl.models import MessageAction, UrlAction
|
||||||
|
|
@ -151,6 +152,7 @@ async def api_lnurl_response(
|
||||||
|
|
||||||
rate = await get_fiat_rate_satoshis(link.currency) if link.currency else 1
|
rate = await get_fiat_rate_satoshis(link.currency) if link.currency else 1
|
||||||
url = request.url_for("lnurlp.api_lnurl_callback", link_id=link.id)
|
url = request.url_for("lnurlp.api_lnurl_callback", link_id=link.id)
|
||||||
|
url = url.replace(path=normalize_path(url.path))
|
||||||
if webhook_data:
|
if webhook_data:
|
||||||
url = url.include_query_params(webhook_data=webhook_data)
|
url = url.include_query_params(webhook_data=webhook_data)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue