Skip to content

Commit 13341de

Browse files
committed
fix: compare origin when sending pending payload
1 parent 734001f commit 13341de

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

testnet/stacks-node/src/event_dispatcher.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,17 @@ impl EventObserver {
438438
};
439439

440440
for (id, url, payload, timeout_ms) in pending_payloads {
441+
let full_url = Url::parse(url.as_str())
442+
.unwrap_or_else(|_| panic!("Event dispatcher: unable to parse {url} as a URL"));
443+
let endport_url = Url::parse(format!("http://{}", &self.endpoint).as_str())
444+
.unwrap_or_else(|_| {
445+
panic!(
446+
"Event dispatcher: unable to parse {} as a URL",
447+
&self.endpoint
448+
)
449+
});
441450
// If the URL is not the same as the endpoint, skip it
442-
if !url.starts_with(&self.endpoint) {
451+
if full_url.origin() != endport_url.origin() {
443452
continue;
444453
}
445454
let timeout = Duration::from_millis(timeout_ms);
@@ -2049,7 +2058,7 @@ mod test {
20492058
let db_path = dir.path().join("event_observers.sqlite");
20502059
let db_path_str = db_path.to_str().unwrap();
20512060
let mut server = mockito::Server::new();
2052-
let endpoint = server.url().to_string();
2061+
let endpoint = server.host_with_port();
20532062
let timeout = Duration::from_secs(5);
20542063
let observer =
20552064
EventObserver::new(Some(dir.path().to_path_buf()), endpoint.clone(), timeout);
@@ -2093,7 +2102,7 @@ mod test {
20932102
let db_path_str = db_path.to_str().unwrap();
20942103

20952104
let mut server = mockito::Server::new();
2096-
let endpoint = server.url().to_string();
2105+
let endpoint = server.host_with_port();
20972106
let timeout = Duration::from_secs(5);
20982107
let observer =
20992108
EventObserver::new(Some(dir.path().to_path_buf()), endpoint.clone(), timeout);

0 commit comments

Comments
 (0)