mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
fix: <ActionForm/>
should check origin correctly before doing a full-page refresh (#1304)
This commit is contained in:
parent
da9183f4b5
commit
b29eb8e032
1 changed files with 16 additions and 8 deletions
|
@ -143,10 +143,7 @@ where
|
|||
match Url::try_from(resp_url.as_str()) {
|
||||
Ok(url) => {
|
||||
if url.origin
|
||||
!= window()
|
||||
.location()
|
||||
.origin()
|
||||
.unwrap_or_default()
|
||||
!= current_window_origin()
|
||||
{
|
||||
_ = window()
|
||||
.location()
|
||||
|
@ -227,10 +224,7 @@ where
|
|||
match Url::try_from(resp_url.as_str()) {
|
||||
Ok(url) => {
|
||||
if url.origin
|
||||
!= window()
|
||||
.location()
|
||||
.hostname()
|
||||
.unwrap_or_default()
|
||||
!= current_window_origin()
|
||||
{
|
||||
_ = window()
|
||||
.location()
|
||||
|
@ -328,6 +322,20 @@ where
|
|||
)
|
||||
}
|
||||
|
||||
fn current_window_origin() -> String {
|
||||
let location = window().location();
|
||||
let protocol = location.protocol().unwrap_or_default();
|
||||
let hostname = location.hostname().unwrap_or_default();
|
||||
let port = location.port().unwrap_or_default();
|
||||
format!(
|
||||
"{}//{}{}{}",
|
||||
protocol,
|
||||
hostname,
|
||||
if port.is_empty() { "" } else { ":" },
|
||||
port
|
||||
)
|
||||
}
|
||||
|
||||
/// Automatically turns a server [Action](leptos_server::Action) into an HTML
|
||||
/// [`form`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form)
|
||||
/// progressively enhanced to use client-side routing.
|
||||
|
|
Loading…
Reference in a new issue