Skip to content

Commit 7e0a95f

Browse files
authored
add origin and query parameters (#5596)
1 parent 545d378 commit 7e0a95f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

reflex/istate/data.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import dataclasses
44
from collections.abc import Mapping
55
from typing import TYPE_CHECKING
6-
from urllib.parse import _NetlocResultMixinStr, urlsplit
6+
from urllib.parse import _NetlocResultMixinStr, parse_qsl, urlsplit
77

88
from reflex import constants
99
from reflex.utils import console, format
@@ -102,8 +102,10 @@ class ReflexURL(str, _NetlocResultMixinStr):
102102
if TYPE_CHECKING:
103103
scheme: str
104104
netloc: str
105+
origin: str
105106
path: str
106107
query: str
108+
query_parameters: Mapping[str, str]
107109
fragment: str
108110

109111
def __new__(cls, url: str):
@@ -121,6 +123,10 @@ def __new__(cls, url: str):
121123
object.__setattr__(obj, "netloc", netloc)
122124
object.__setattr__(obj, "path", path)
123125
object.__setattr__(obj, "query", query)
126+
object.__setattr__(obj, "origin", f"{scheme}://{netloc}")
127+
object.__setattr__(
128+
obj, "query_parameters", _FrozenDictStrStr(**dict(parse_qsl(query)))
129+
)
124130
object.__setattr__(obj, "fragment", fragment)
125131
return obj
126132

0 commit comments

Comments
 (0)