Fix page if incorrect formatted url
This commit is contained in:
@@ -58,11 +58,30 @@
|
||||
<p>
|
||||
You have reached the end of the IPv4 Internet.
|
||||
|
||||
<% if (it.back_to_url) { %>
|
||||
<% if (it.back_to_url) {
|
||||
let normalizedUrl = it.back_to_url;
|
||||
let displayDomain = it.domain;
|
||||
|
||||
try {
|
||||
if (it.back_to_url) {
|
||||
// Normalize URL by adding protocol if missing
|
||||
if (!it.back_to_url.startsWith('http')) {
|
||||
normalizedUrl = `http://${it.back_to_url}`;
|
||||
}
|
||||
|
||||
const url = new URL(normalizedUrl);
|
||||
displayDomain = url.hostname;
|
||||
}
|
||||
} catch (e) {
|
||||
// Fall back to original values if parsing fails
|
||||
normalizedUrl = it.back_to_url;
|
||||
displayDomain = it.domain || it.back_to_url;
|
||||
}
|
||||
%>
|
||||
<p>
|
||||
The site <%= it.domain %> is not reachable by IPv4.
|
||||
The site <%= displayDomain %> is not reachable by IPv4.
|
||||
To access
|
||||
<a href="<%= it.back_to_url %>" target="_blank"><%= it.domain %></a>,
|
||||
<a href="<%= normalizedUrl %>" target="_blank"><%= displayDomain %></a>,
|
||||
you need to enable IPv6 on your computer.
|
||||
</p>
|
||||
<% } %>
|
||||
|
||||
Reference in New Issue
Block a user