Skip to content

Hide native title when HTML <title> is not present or blank - #204

Merged
mbarta merged 2 commits into
hotwired:mainfrom
leonvogt:hide-title
Nov 3, 2026
Merged

mbarta merged 2 commits into
hotwired:mainfrom
leonvogt:hide-title

Conversation

@leonvogt

Copy link
Copy Markdown
Contributor

Android's WebView returns the URL when a page has no HTML <title>.
With this PR, instead of showing the URL, it shows nothing - like in Hotwire Native iOS.

Comment on lines +392 to +395
substringAfter("://")
.removePrefix("www.")
.replace("%20", " ")
.trimEnd('/')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First I had a simpler check, but the problem is that, webView.url contains the schema while webView.title doesnt':

webView.url = http://192.168.42.51:3000/dashboard
webView.title = 192.168.42.51:3000/dashboard

To also handle the case of www.domain.com sites, we we normalize both strings the same way before comparing them.

leonvogt and others added 2 commits November 3, 2026 17:00
The check that hides WebView's URL fallback title now lives in
displayTitle(), so it can be tested without a WebView. The tests cover
http and https URLs, a port, www, a bare host, decoded spaces,
about:blank, and a real title that should stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mbarta mbarta left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mbarta
mbarta merged commit 1ec18fd into hotwired:main Nov 3, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants