Skip to content

Commit c88406e

Browse files
authored
Update frames.erb
1 parent 7cb3fc5 commit c88406e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

templates/default/fulldoc/html/frames.erb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
<title><%= options.title %></title>
66
</head>
77
<script type="text/javascript">
8-
var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
9-
var name = match ? match[1] : '<%= url_for_main %>';
10-
name = name.replace(/^((\w*):)?[\/\\]*/gm, '').trim();
11-
window.top.location.replace(name)
8+
try {
9+
var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
10+
var name = match ? match[1] : '<%= url_for_main %>';
11+
var url = new URL(name, location.href);
12+
window.top.location.replace(url.origin === location.origin ? name : '<%= url_for_main %>');
13+
} catch (e) {
14+
window.top.location.replace('<%= url_for_main %>');
15+
}
1216
</script>
1317
<noscript>
1418
<h1>Oops!</h1>

0 commit comments

Comments
 (0)