Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions templates/default/fulldoc/html/frames.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
<title><%= options.title %></title>
</head>
<script type="text/javascript">
var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
var name = match ? match[1] : '<%= url_for_main %>';
name = name.replace(/^((\w*):)?[\/\\]*/gm, '').trim();
window.top.location.replace(name)
var mainUrl = '<%= url_for_main %>'
try {
var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
var name = match ? match[1] : mainUrl;
var url = new URL(name, location.href);
window.top.location.replace(url.origin === location.origin ? name : mainUrl);
} catch (e) {
window.top.location.replace(mainUrl);
}
Comment on lines 8 to 16
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
try {
var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
var name = match ? match[1] : '<%= url_for_main %>';
var url = new URL(name, location.href);
window.top.location.replace(url.origin === location.origin ? name : '<%= url_for_main %>');
} catch (e) {
window.top.location.replace('<%= url_for_main %>');
}
try {
var mainUrl = '<%= url_for_main %>';
var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
var name = match ? match[1] : mainUrl;
var url = new URL(name, location.href);
window.top.location.replace(url.origin === location.origin ? name : mainUrl);
} catch (e) {
window.top.location.replace(mainUrl);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The assignment must be outside the try catch loop

</script>
<noscript>
<h1>Oops!</h1>
Expand Down