templates/default/fulldoc/html/frames.erb in yard-0.9.35 vs templates/default/fulldoc/html/frames.erb in yard-0.9.36
- old
+ new
@@ -3,13 +3,18 @@
<head>
<meta charset="<%= charset %>">
<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);
+}
</script>
<noscript>
<h1>Oops!</h1>
<h2>YARD requires JavaScript!</h2>
</noscript>