Skip to content

Commit 78bb229

Browse files
committed
Fix basehref for search box on non-root cases
1 parent fc3fe59 commit 78bb229

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/resources/script.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ function initSearch(name) {
240240
}
241241

242242
var jsonReq = new XMLHttpRequest();
243-
jsonReq.open('GET', 'index.json', true);
243+
var scriptUrl = URI(document.getElementById("dartdoc_script_js"));
244+
245+
jsonReq.open('GET', URI(scriptUrl.directory() + '/../..').absoluteTo(scriptUrl) + '/index.json', true);
244246
jsonReq.addEventListener('load', function() {
245247
searchIndex = JSON.parse(jsonReq.responseText);
246248
initTypeahead();

lib/templates/_footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<script src="{{^useBaseHref}}%%__HTMLBASE_dartdoc_internal__%%{{/useBaseHref}}static-assets/typeahead.bundle.min.js"></script>
1717
<script src="{{^useBaseHref}}%%__HTMLBASE_dartdoc_internal__%%{{/useBaseHref}}static-assets/highlight.pack.js"></script>
1818
<script src="{{^useBaseHref}}%%__HTMLBASE_dartdoc_internal__%%{{/useBaseHref}}static-assets/URI.js"></script>
19-
<script src="{{^useBaseHref}}%%__HTMLBASE_dartdoc_internal__%%{{/useBaseHref}}static-assets/script.js"></script>
19+
<script id="dartdoc_script_js" src="{{^useBaseHref}}%%__HTMLBASE_dartdoc_internal__%%{{/useBaseHref}}static-assets/script.js"></script>
2020
<!-- footer placeholder -->
2121

2222
</body>

0 commit comments

Comments
 (0)