Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: issue with localhost

Luigi Agosti4271d758ac77
diff --git a/internal/bridge/state.go b/internal/bridge/state.go
index 74235207..fa351998 100644
--- a/internal/bridge/state.go
+++ b/internal/bridge/state.go
@@ -34,7 +34,9 @@ type SessionState struct {
// IsTransientURL returns true for URLs that should not be shown in the UI
// or persisted to session state (about:blank, chrome://, etc.).
-func IsTransientURL(url string) bool {
+// serverPort is the pinchtab server port so that only pinchtab's own
+// dashboard URLs on localhost are filtered, not user-navigated localhost sites.
+func IsTransientURL(url, serverPort string) bool {
switch url {
case "about:blank", "chrome://newtab/", "chrome://new-tab-page/":
return true
@@ -43,7 +45,7 @@ func IsTransientURL(url string) bool {
strings.HasPrefix(url, "chrome-extension://") ||
strings.HasPrefix(url, "devtools://") ||
strings.HasPrefix(url, "file://") ||
- strings.Contains(url, "localhost:")
+ (serverPort != "" && strings.Contains(url, "localhost:"+serverPort))
}
func safeURLHostForLog(raw string) string {
@@ -135,7 +137,7 @@ func (b *Bridge) SaveState() {
tabs := make([]TabState, 0, len(targets))
seen := make(map[string]bool, len(targets))
for _, t := range targets {
- if t.URL == "" || IsTransientURL(t.URL) {
+ if t.URL == "" || IsTransientURL(t.URL, b.Config.Port) {
continue
}
if seen[t.URL] {
diff --git a/internal/bridge/state_test.go b/internal/bridge/state_test.go
index 2090ac1f..6c6fdac8 100644
--- a/internal/bridge/state_test.go
+++ b/internal/bridge/state_test.go
@@ -127,6 +127,8 @@ func TestWasUncleanExit_Normal(t *testing.T) {
}
func TestIsTransientURL(t *testing.T) {
+ const serverPort = "9867"
+
transient := []string{
"about:blank",
"chrome://newtab/",
@@ -136,10 +138,9 @@ func TestIsTransientURL(t *testing.T) {
"devtools://devtools/inspector.html",
"file:///tmp/test.html",
"http://localhost:9867/welcome",
- "http://localhost:3000/dashboard",
}
for _, u := range transient {
- if !IsTransientURL(u) {
+ if !IsTransientURL(u, serverPort) {
t.Errorf("expected transient: %s", u)
}
}
@@ -149,9 +150,11 @@ func TestIsTransientURL(t *testing.T) {
"https://github.com/pinchtab/pinchtab",
"https://www.google.com/search?q=test",
"https://httpbin.org/get",
+ "http://localhost:3000/dashboard",
+ "http://localhost:3001/en/access",
}
for _, u := range persistent {
- if IsTransientURL(u) {
+ if IsTransientURL(u, serverPort) {
t.Errorf("expected persistent: %s", u)
}
}