Skip to content

Commit 99cd7b1

Browse files
authored
need to copy scheme from base url (#1118)
* need to copy scheme from base url * add changelog entry
1 parent c42d85c commit 99cd7b1

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

docs/source/about/changelog.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ more info, see the :ref:`Contributor Guide <Creating a Changelog Entry>`.
2323
Unreleased
2424
----------
2525

26-
Nothing yet...
26+
**Fixed**
27+
28+
- :pull:`1118` - `module_from_template` is broken with a recent release of `requests`
2729

2830

2931
v1.0.2

src/py/reactpy/reactpy/web/utils.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import re
33
from pathlib import Path, PurePosixPath
4-
from urllib.parse import urlparse
4+
from urllib.parse import urlparse, urlunparse
55

66
import requests
77

@@ -130,7 +130,11 @@ def resolve_module_exports_from_source(
130130

131131
def _resolve_relative_url(base_url: str, rel_url: str) -> str:
132132
if not rel_url.startswith("."):
133-
return rel_url
133+
if rel_url.startswith("/"):
134+
# copy scheme and hostname from base_url
135+
return urlunparse(urlparse(base_url)[:2] + urlparse(rel_url)[2:])
136+
else:
137+
return rel_url
134138

135139
base_url = base_url.rsplit("/", 1)[0]
136140

temp.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from fastapi import FastAPI
2+
3+
from reactpy import html, web
4+
from reactpy.backend.fastapi import configure
5+
6+
mui = web.module_from_template(
7+
"react",
8+
"@mui/x-date-pickers",
9+
fallback="please wait loading...",
10+
)
11+
12+
13+
# Create calendar with material ui
14+
DatePicker = web.export(mui, "DatePicker")
15+
16+
17+
def Mycalender():
18+
return html.div(
19+
DatePicker(
20+
{
21+
"label": "Basic date picker",
22+
},
23+
"my calender",
24+
),
25+
)
26+
27+
28+
app = FastAPI()
29+
configure(app, Mycalender)

0 commit comments

Comments
 (0)